// GainPzPage.cpp : implementation file // #include "stdafx.h" #include "afxpriv.h" // afxpriv.h has WM_COMMANDHELP id #include "GainPzPageRes.h" #include "GainPzPage.h" #include ".\GainPzPage.h" #include #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CGainPzPage property page IMPLEMENT_DYNCREATE(CGainPzPage, CCfgPropPage) //#define IDD_GAINPZ_PAGE 108 //CGainPzPage::CGainPzPage() : CCfgPropPage(CGainPzPage::IDD) CGainPzPage::CGainPzPage() : CCfgPropPage("IDD_GAINPZ_PAGE") { //{{AFX_DATA_INIT(CGainPzPage) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } CGainPzPage::~CGainPzPage() { } void CGainPzPage::DoDataExchange(CDataExchange* pDX) { CCfgPropPage::DoDataExchange(pDX); //{{AFX_DATA_MAP(CGainPzPage) //}}AFX_DATA_MAP DDX_Control(pDX, IDC_STATIC_GAINPZ_PAGE, m_GainPzPageLabel); DDX_Control(pDX, IDC_OPT_COMBO_GAIA, m_CoarseGain_GAIA_index); DDX_Control(pDX, IDC_OPT_COMBO_GAIA2, m_CoarseGain_GAIA_value); DDX_Control(pDX, IDC_STATIC_GAIN_ADVANCED, m_GainAdvancedLabel); DDX_Control(pDX, IDC_STATIC_GAIN_STANDARD, m_GainStandardLabel); DDX_Control(pDX, IDC_STATIC_HV_WARNING, m_PowerHvWarning); } BEGIN_MESSAGE_MAP(CGainPzPage, CCfgPropPage) //{{AFX_MSG_MAP(CGainPzPage) //}}AFX_MSG_MAP ON_CBN_SELCHANGE(IDC_OPT_COMBO_RESL, OnCbnSelchangeOptComboResl) ON_CBN_SELCHANGE(IDC_OPT_COMBO_AINP, OnCbnSelchangeOptComboAinp) ON_CBN_SELCHANGE(IDC_OPT_COMBO_INOF, OnCbnSelchangeOptComboInof) ON_CBN_SELCHANGE(IDC_OPT_COMBO_PAPZ, OnCbnSelchangeOptComboPapz) ON_EN_CHANGE(IDC_OPT_TEXT_PAPZ, OnEnChangeOptTextPapz) ON_EN_CHANGE(IDC_OPT_TEXT_RESL, OnEnChangeOptTextResl) ON_EN_CHANGE(IDC_OPT_TEXT_INOF, OnEnChangeOptTextInof) ON_EN_CHANGE(IDC_OPT_TEXT_GAIN, OnEnChangeOptTextGain) ON_CBN_SELCHANGE(IDC_OPT_COMBO_GAIA, OnCbnSelchangeOptComboGaia) ON_EN_CHANGE(IDC_OPT_TEXT_GAIF, OnEnChangeOptTextGaif) ON_BN_CLICKED(IDC_BUTTON_FINE_GAIN_ENTER, OnBnClickedButtonFineGainEnter) ON_CBN_SELCHANGE(IDC_OPT_COMBO_GAIN_SELECT, OnCbnSelchangeOptComboGainSelect) ON_BN_CLICKED(IDC_BUTTON_COARSE_FINE_TO_TOTAL, OnBnClickedButtonCoarseFineToTotal) ON_BN_CLICKED(IDC_BUTTON_TOTAL_TO_COARSE_FINE, OnBnClickedButtonTotalToCoarseFine) ON_CBN_SELCHANGE(IDC_OPT_COMBO_GAIA2, OnCbnSelchangeOptComboGaia2) ON_CBN_SELCHANGE(IDC_OPT_COMBO_RESL2, OnCbnSelchangeOptComboResl2) ON_COMMAND(ID_HELP, OnHelp) ON_WM_HELPINFO() END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CGainPzPage message handlers BOOL CGainPzPage::OnSetActive() { // TODO: Add your specialized code here and/or call the base class if (s.ReloadCfg) { InitControls(); } else { SetHvPowerWarning(); } return CCfgPropPage::OnSetActive(); } BOOL CGainPzPage::OnInitDialog() { CCfgPropPage::OnInitDialog(); BuildToolTips(); m_GainPzPageLabel .SetFontName("Arial") .SetFontSize(24) .SetTextColor(RGB(0,0,255)) .SetBkColor(RGB(244, 243, 238)) .SetFontItalic(TRUE) .SetFontBold(TRUE); m_GainAdvancedLabel .SetFontName("Arial") .SetFontSize(18) .SetTextColor(RGB(0, 70, 213)) .SetBkColor(RGB(249, 248, 247)) .SetFontItalic(TRUE) .SetFontBold(FALSE); m_GainStandardLabel .SetFontName("Arial") .SetFontSize(18) .SetTextColor(RGB(0, 70, 213)) .SetBkColor(RGB(252, 252, 253)) .SetFontItalic(TRUE); m_PowerHvWarning .SetFontName("Arial") .SetFontSize(12) .SetTextColor(RGB(255, 0, 0)) .SetBkColor(RGB(247, 246, 243)) .SetFontItalic(FALSE) .SetFontBold(TRUE); InitControls(); // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } //dciRESL RESL IDC_OPT_COMBO_RESL IDC_OPT_TEXT_RESL dctCboTxt dcgGainPZ Reset Lockout uS //dciAINP AINP IDC_OPT_COMBO_AINP 0 dctCbo dcgGainPZ Analog Input Pos/Neg //dciINOF INOF IDC_OPT_COMBO_INOF IDC_OPT_TEXT_INOF dctCboTxt dcgGainPZ Input Offset mV //dciGAIN GAIN 0 IDC_OPT_TEXT_GAIN dctTxt dcgGainPZ Total Gain (Analog * Fine) x //dciPAPZ PAPZ IDC_OPT_COMBO_PAPZ IDC_OPT_TEXT_PAPZ dctCboTxt dcgPower Pole-Zero "uS", "34.5uS to 8773uS"); // PX5 HPGe and DP5 Dx Configuration K //dciPAPZ PAPZ IDC_OPT_COMBO_PAPZ IDC_OPT_TEXT_PAPZ dctCboTxt dcgPower Pole-Zero "uS", "34.5 to 103.5uS"); // DP5 Dx Configuration L //dciPAPZ PAPZ IDC_OPT_COMBO_PAPZ IDC_OPT_TEXT_PAPZ dctCboTxt dcgPower Pole-Zero "uS", "91.6uS to 1203uS"); void CGainPzPage::InitControls() { BOOL bEnablePAPZ=FALSE; int iShowNewRESL=SW_HIDE; int iShowOldRESL=SW_SHOW; int DppType; BOOL bHPGePAPZ=FALSE; bool isDP5_DxK=false; bool isDP5_DxL=false; DppType = s.profile->device_type; bEnableNewRESL=FALSE; // start as old RESL, test for new RESL HWND hPage = this->GetSafeHwnd(); // Select gain table for analog gain values int GainTable = s.profile->device_type - dppDP5; bEnablePAPZ = (DppType == dppPX5); /////////////////////////////////////////////// //0.750-1.250 All devices except DP5X //0.600-1.400 DP5X dblGAIF_Max = 1.250; dblGAIF_Min = 0.750; GetDlgItem(IDC_OPT_LIMITS_GAIF)->SetWindowText("0.750-1.250"); // SEE END OF CGainPzPage::InitControls for more details /////////////////////////////////////////////// // 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; //A==0x00,K==0x0A, PAPZ Enabled for DP5 Dx Configuration K if ((s.DP5Stat.m_DP5_Status.DPP_ECO & 0x0F) == 0x0A) { // DP5 Dx Configuration K isDP5_DxK = true; bEnablePAPZ = true; } if ((s.DP5Stat.m_DP5_Status.DPP_ECO & 0x0F) == 0x0B) { // DP5 Dx Configuration L isDP5_DxL = true; bEnablePAPZ = true; } } if (s.DP5Stat.m_DP5_Status.DPP_options == PX5_OPTION_HPGe_HVPS) { bHPGePAPZ = true; } if (bEnablePAPZ && (s.profile->device_type == dppDP5)) { // DP5 Dx Configuration K,L Only bHPGePAPZ = true; // Remove or update logic } if (((s.DppConfig.Firmware == 0x67) && (s.DppConfig.Build >= 4)) || (s.DppConfig.Firmware > 0x67)) { bEnableNewRESL=TRUE; // Needs new RESL controls iShowNewRESL=SW_SHOW; iShowOldRESL=SW_HIDE; } GetDlgItem(IDC_OPT_FRAME_RESL)->ShowWindow(iShowNewRESL); GetDlgItem(IDC_OPT_COMBO_RESL)->ShowWindow(iShowNewRESL); GetDlgItem(IDC_OPT_LIMITS_RESL)->ShowWindow(iShowNewRESL); GetDlgItem(IDC_OPT_TEXT_RESL)->ShowWindow(iShowNewRESL); GetDlgItem(IDC_OPT_UNITS_RESL)->ShowWindow(iShowNewRESL); GetDlgItem(IDC_OPT_FRAME_RESL2)->ShowWindow(iShowOldRESL); GetDlgItem(IDC_OPT_COMBO_RESL2)->ShowWindow(iShowOldRESL); GetDlgItem(IDC_OPT_UNITS_RESL2)->ShowWindow(iShowOldRESL); GetDlgItem(IDC_OPT_FRAME_PAPZ)->EnableWindow(bEnablePAPZ); GetDlgItem(IDC_OPT_COMBO_PAPZ)->EnableWindow(bEnablePAPZ); GetDlgItem(IDC_OPT_TEXT_PAPZ)->EnableWindow(bEnablePAPZ); GetDlgItem(IDC_OPT_LIMITS_PAPZ)->EnableWindow(bEnablePAPZ); GetDlgItem(IDC_OPT_UNITS_PAPZ)->EnableWindow(bEnablePAPZ); // Select gain table for analog gain values //int GainTable = s.profile->device_type - dppDP5; if (GainTable < MinGainTable) { GainTable = MinGainTable; } if (GainTable > MaxGainTable) { GainTable = MaxGainTable; } DppGain.GainTable = (DppAGainTable)GainTable; DppGain.ptrGainTable = DppGain.GetGainTablePtr(DppGain.GainTable); DppGain.GainTableCount = DppGain.GetGainCount(DppGain.GainTable); DppGain.MinGain = DppGain.GetTotalGainLimitsMin(DppGain.GainTable); DppGain.MaxGain = DppGain.GetTotalGainLimitsMax(DppGain.GainTable); DppGain.LoadGainTableValues(&m_CoarseGain_GAIA_value, DppGain.GainTable); DppGain.LoadGainTableIndexes(&m_CoarseGain_GAIA_index, DppGain.GainTable); SetDetResetValues(IDC_OPT_COMBO_RESL2,s.DppConfig.b80MHzModeCfg); InitDlgItem(hPage,s.m_DP5Cfg[dciRESL]); InitDlgItem(hPage,s.m_DP5Cfg[dciAINP]); InitDlgItem(hPage,s.m_DP5Cfg[dciINOF]); InitDlgItem(hPage,s.m_DP5Cfg[dciGAIN]); InitDlgItem(hPage,s.m_DP5Cfg[dciGAIA]); InitDlgItem(hPage,s.m_DP5Cfg[dciGAIF]); InitDlgItem(hPage,s.m_DP5Cfg[dciPAPZ]); CboUpdate(dciPAPZ); if (bHPGePAPZ && !(isDP5_DxK || isDP5_DxL)) { // PX5 HPGe GetDlgItem(IDC_OPT_LIMITS_PAPZ)->SetWindowText("34.5uS to 103.5uS"); } else if (bHPGePAPZ && isDP5_DxK) { // DP5 Dx Configuration K GetDlgItem(IDC_OPT_LIMITS_PAPZ)->SetWindowText("34.5uS to 103.5uS"); } else if (bHPGePAPZ && isDP5_DxL) { // DP5 Dx Configuration L GetDlgItem(IDC_OPT_LIMITS_PAPZ)->SetWindowText("91.6uS to 1203uS"); } else { GetDlgItem(IDC_OPT_LIMITS_PAPZ)->SetWindowText("34.5uS to 8773uS"); } CboUpdate(dciRESL); CboUpdate(dciAINP); CboUpdate(dciINOF); //CboUpdate(dciGAIA); OnEnChangeOptTextGaif(); // update fine gain value OnCbnSelchangeOptComboGaia(); // update coarse gain text display also OnBnClickedButtonFineGainEnter(); CComboBox* pCombo = (CComboBox*)GetDlgItem(IDC_OPT_COMBO_GAIN_SELECT); pCombo->SetCurSel(s.profile->SendCoarseFineGain); UpdateOptComboGAIA(); InitCombo(hPage,s.m_DP5Cfg[dciRESL],IDC_OPT_COMBO_RESL2); // reset the Total Gain Range To Current Gain Table Values CString strTotalGainRange; strTotalGainRange = DppGain.GetTotalGainLimitsLabel(DppGain.GainTable); GetDlgItem(IDC_OPT_LIMITS_GAIN)->SetWindowText(strTotalGainRange); // correct the total gain value if out of range CString strTotalGain; GetDlgItem(IDC_OPT_TEXT_GAIN)->GetWindowText(strTotalGain); if (! DppGain.isInTotalGainRange(strTotalGain, DppGain.GainTable)) { strTotalGain = DppGain.FixTotalGainRange(strTotalGain, DppGain.GainTable); GetDlgItem(IDC_OPT_TEXT_GAIN)->SetWindowText(strTotalGain); } //if (s.profile->device_type == dppMCA8000D) { // ShowMCA8000D_Controls(SW_HIDE); // CheckMCA8000D_FineGain(); // verify the fine gain is at 1 if not, set it to 1 // GetDlgItem(IDC_OPT_FRAME_GAIA)->SetWindowText("Input Range"); //} else { // ShowMCA8000D_Controls(SW_SHOW); // GetDlgItem(IDC_OPT_FRAME_GAIA)->SetWindowText("Coarse Gain"); //} if (DppType == dppDP5X) { dblGAIF_Max = 1.400; dblGAIF_Min = 0.600; GetDlgItem(IDC_OPT_LIMITS_GAIF)->SetWindowText("0.600-1.400"); } else { dblGAIF_Max = 1.250; dblGAIF_Min = 0.750; GetDlgItem(IDC_OPT_LIMITS_GAIF)->SetWindowText("0.750-1.250"); } } void CGainPzPage::CheckMCA8000D_FineGain() { CString strGAIF; double dblGAIF; GetDlgItem(IDC_OPT_TEXT_GAIF)->GetWindowText(strGAIF); if (strGAIF.GetLength() > 0) { dblGAIF = atof(strGAIF); if (dblGAIF != 1) { strGAIF = "1"; dblGAIF = 1; GetDlgItem(IDC_OPT_TEXT_GAIF)->SetWindowText(strGAIF); } } else { strGAIF = "1"; dblGAIF = 1; GetDlgItem(IDC_OPT_TEXT_GAIF)->SetWindowText(strGAIF); } UpdateGainValue(); // update gain value display } void CGainPzPage::ShowMCA8000D_Controls(int iShowWin) { GetDlgItem(IDC_BUTTON_FINE_GAIN_ENTER)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_COMBO_AINP)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_COMBO_GAIN_SELECT)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_COMBO_INOF)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_COMBO_RESL)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_COMBO_RESL2)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_FRAME_AINP)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_FRAME_GAIF)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_FRAME_GAIN)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_FRAME_INOF)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_FRAME_RESL)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_FRAME_RESL2)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_LIMITS_GAIF)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_LIMITS_GAIN)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_LIMITS_INOF)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_LIMITS_RESL)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_TEXT_GAIF)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_TEXT_GAIN)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_TEXT_INOF)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_TEXT_RESL)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_UNITS_GAIF)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_UNITS_GAIN)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_UNITS_INOF)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_UNITS_RESL)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_UNITS_RESL2)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_VALUE_GAIN)->ShowWindow(iShowWin); GetDlgItem(IDC_STATIC_AVANCED_GAIN_CONTROL)->ShowWindow(iShowWin); GetDlgItem(IDC_STATIC_GAINPZ_PAGE)->ShowWindow(iShowWin); GetDlgItem(IDC_STATIC_GAIN_ADVANCED)->ShowWindow(iShowWin); GetDlgItem(IDC_STATIC_GAIN_BASIC)->ShowWindow(iShowWin); GetDlgItem(IDC_STATIC_GAIN_STANDARD)->ShowWindow(iShowWin); GetDlgItem(IDC_STATIC_TOTAL_OR_BOTH_LABEL)->ShowWindow(iShowWin); GetDlgItem(IDC_BUTTON_TOTAL_TO_COARSE_FINE)->ShowWindow(iShowWin); GetDlgItem(IDC_BUTTON_COARSE_FINE_TO_TOTAL)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_COMBO_PAPZ)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_FRAME_PAPZ)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_LIMITS_PAPZ)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_TEXT_PAPZ)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_UNITS_PAPZ)->ShowWindow(iShowWin); //GetDlgItem(IDC_OPT_FRAME_GAIA)->ShowWindow(iShowWin); //GetDlgItem(IDC_OPT_COMBO_GAIA2)->ShowWindow(iShowWin); //GetDlgItem(IDC_OPT_VALUE_GAIA)->ShowWindow(iShowWin); } void CGainPzPage::InitDlgItem(HWND hDlg, DP5_CONFIGURATION cfg) { int cboDP5CtrlID = cfg.ListCtrlID; int txtDP5CtrlID = cfg.TextCtrlID; CString strVal = cfg.Setting; int idxList; CString strUnits; CString strLimits; 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 if ((cfg.CtrlType & dctTxt) > 0) { // if cbotxt must find mask, else set to 0 cfg.TextValue = cfg.Setting; // overwrite if currently editing idxList = s.CtrlUtil.FindCboIdx(hDlg,cboDP5CtrlID,"#"); if (idxList == LB_ERR) { // mask begins with + idxList = s.CtrlUtil.FindCboIdx(hDlg,cboDP5CtrlID,"+"); } if (idxList == LB_ERR) { // mask begins with - idxList = s.CtrlUtil.FindCboIdx(hDlg,cboDP5CtrlID,"-"); } if (idxList == LB_ERR) { // not found default to 0 idxList = 0; } } else { idxList = 0; // set to first item } } cb.SetCurSel(idxList); } if ((cfg.CtrlType & dctTxt) > 0) { if ((cfg.CtrlType & dctCbo) == 0) { // cbo update above if (cfg.Setting.GetLength() > 0) { cfg.TextValue = cfg.Setting; } } GetDlgItem(txtDP5CtrlID)->SetWindowText(cfg.TextValue); strUnits = cfg.Units; strLimits = cfg.Limits; switch (txtDP5CtrlID) { case IDC_OPT_TEXT_RESL: UNIT_INIT(RESL, strUnits); LIMIT_INIT(RESL, strLimits); break; case IDC_OPT_TEXT_INOF: UNIT_INIT(INOF, strUnits); LIMIT_INIT(INOF, strLimits); break; case IDC_OPT_TEXT_GAIN: UNIT_INIT(GAIN, strUnits); LIMIT_INIT(GAIN, strLimits); break; case IDC_OPT_TEXT_GAIF: UNIT_INIT(GAIF, strUnits); LIMIT_INIT(GAIF, strLimits); break; case IDC_OPT_TEXT_PAPZ: UNIT_INIT(PAPZ, strUnits); LIMIT_INIT(PAPZ, strLimits); break; } } } // pass dci id to update combo control and display edit controls if any void CGainPzPage::CboUpdate(int nID_dci) { CString strCboText; int nID; int CmdShow; //BOOL isText; 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; if (nID_dci == dciAINP) { if (strCboText.GetLength() > 0) { s.DppConfig.bAnalogPolarity = FALSE; if (strCboText.Find("PO") > -1) { s.DppConfig.bAnalogPolarity = TRUE; } SetHvPowerWarning(); } } } else { return; } if (s.m_DP5Cfg[nID_dci].CtrlType == dctCboTxt) { if (strCboText.Find('#') >= 0) { CmdShow = SW_SHOW; } else { CmdShow = SW_HIDE; } switch (nID) { case IDC_OPT_COMBO_RESL: if (bEnableNewRESL) { ALL_VIS(RESL, CmdShow); CBO_TEXT_VIS(RESL, (CmdShow!=0)); } //CboTextVis(IDC_OPT_COMBO_RESL,IDC_OPT_TEXT_RESL,(CmdShow!=0)); break; case IDC_OPT_COMBO_INOF: ALL_VIS(INOF, CmdShow); CBO_TEXT_VIS(INOF, (CmdShow!=0)); //CboTextVis(IDC_OPT_COMBO_INOF,IDC_OPT_TEXT_INOF,(CmdShow!=0)); break; case IDC_OPT_COMBO_PAPZ: ALL_VIS(PAPZ, CmdShow); CBO_TEXT_VIS(PAPZ, (CmdShow!=0)); break; } } SetModified(TRUE); } //CBO_TEXT_VIS(RESL, (CmdShow!=0)); //CboTextVis(IDC_OPT_COMBO_RESL,IDC_OPT_TEXT_RESL,(CmdShow!=0)); //void CboTextVis(int nIdCbox, int nIdEdit, BOOL isText); void CGainPzPage::CboTextVis(int nIdCbox, int nIdEdit, BOOL isText) { UINT ddSize; RECT lpRect; CEdit* pEdit; CComboBox* pCombo; int btnSize = 20; pEdit = (CEdit*)GetDlgItem(nIdEdit); // cast to edit for rect pEdit->GetRect(&lpRect); // get rect ddSize = lpRect.right - lpRect.left; // save width if (isText) { GetDlgItem(nIdEdit)->ShowWindow(SW_SHOW); pCombo = (CComboBox*)GetDlgItem(nIdCbox); pCombo->GetWindowRect(&lpRect); ScreenToClient(&lpRect); //int ddSize1 = lpRect.right - lpRect.left; // save width //TRACE("Combo Edit %d\r\n",ddSize1); lpRect.right = lpRect.left + btnSize; pCombo->MoveWindow(&lpRect,TRUE); pCombo->SetDroppedWidth(ddSize + btnSize); } else { GetDlgItem(nIdEdit)->ShowWindow(SW_HIDE); // hide edit //TRACE("Edit %d\r\n",ddSize); pCombo = (CComboBox*)GetDlgItem(nIdCbox); // cast to combo pCombo->GetWindowRect(&lpRect); // get win size ScreenToClient(&lpRect); // adjust to screen //int ddSize2 = lpRect.right - lpRect.left; // save width //TRACE("Combo %d\r\n",ddSize2); lpRect.right = lpRect.left + ddSize + btnSize; // get restored combo size pCombo->MoveWindow(&lpRect,TRUE); // restore combo pCombo->SetDroppedWidth(ddSize); // restore combo } } // pass dci id to update combo control and display edit controls if any void CGainPzPage::TextUpdate(int nID_dci) { CString strText; int nID; nID = s.m_DP5Cfg[nID_dci].TextCtrlID; if (nID == NULL) { return; } GetDlgItem(nID)->GetWindowText(strText); s.m_DP5Cfg[nID_dci].TextValue = strText; SetModified(TRUE); } void CGainPzPage::OnCbnSelchangeOptComboResl() { CboUpdate(dciRESL); } void CGainPzPage::OnCbnSelchangeOptComboAinp() { CboUpdate(dciAINP); } void CGainPzPage::OnCbnSelchangeOptComboInof() { CboUpdate(dciINOF); } void CGainPzPage::OnCbnSelchangeOptComboPapz() { CboUpdate(dciPAPZ); } void CGainPzPage::OnCbnSelchangeOptComboGaia() { CboUpdate(dciGAIA); // Update the Visual Display CString strAnalogGain; CString strFormat="%.3fx"; if (s.profile->device_type == dppMCA8000D) { strFormat="%.0fx"; } strAnalogGain = ""; CComboBox &cb = *(CComboBox *) GetDlgItem(IDC_OPT_COMBO_GAIA); int idx = cb.GetCurSel(); if ((idx > LB_ERR) && (idx < DppGain.GainTableCount)) { strAnalogGain.Format(strFormat, DppGain.ptrGainTable[idx]); } GetDlgItem(IDC_OPT_VALUE_GAIA)->SetWindowText(strAnalogGain); UpdateGainValue(); // update gain value display } void CGainPzPage::OnEnChangeOptTextPapz() { TextUpdate(dciPAPZ); } void CGainPzPage::OnEnChangeOptTextResl() { TextUpdate(dciRESL); } void CGainPzPage::OnEnChangeOptTextInof() { TextUpdate(dciINOF); } void CGainPzPage::OnEnChangeOptTextGain() { TextUpdate(dciGAIN); } void CGainPzPage::UpdateGainValue() { // get coarse gain CString strAnalogGain; double dblCoarseGain; strAnalogGain = ""; CComboBox &cb = *(CComboBox *) GetDlgItem(IDC_OPT_COMBO_GAIA); int idx = cb.GetCurSel(); if ((idx > LB_ERR) && (idx < DppGain.GainTableCount)) { dblCoarseGain = DppGain.ptrGainTable[idx]; } else { dblCoarseGain = DppGain.ptrGainTable[DppGain.GainTableCount - 1]; } // get fine gain CString strGAIF; double dblFineGain; GetDlgItem(IDC_OPT_TEXT_GAIF)->GetWindowText(strGAIF); if (strGAIF.GetLength() > 0) { dblFineGain = atof(strGAIF); if ((dblFineGain > 1.250) || (dblFineGain < 0.750)) { dblFineGain = 1.000; } } else { dblFineGain = 1.000; } double dblTotalGain; // calculate total gain dblTotalGain = dblCoarseGain * dblFineGain; // check for errors if (dblTotalGain < DppGain.MinGain) { dblTotalGain = DppGain.MinGain; } else if (dblTotalGain > DppGain.MaxGain) { dblTotalGain = DppGain.MaxGain; } strAnalogGain.Format("%.3fx",dblTotalGain); GetDlgItem(IDC_OPT_VALUE_GAIN)->SetWindowText(strAnalogGain); } void CGainPzPage::OnEnChangeOptTextGaif() { TextUpdate(dciGAIF); } BOOL CGainPzPage::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class //================================================================== MSG msg = *pMsg; if (msg.message == WM_MOUSEMOVE) { // Relay events to the tooltip control msg.hwnd = (HWND)m_ToolTip.SendMessage(TTM_WINDOWFROMPOINT, 0, (LPARAM)&msg.pt); CPoint pt = pMsg->pt; ::ScreenToClient(msg.hwnd, &pt); msg.lParam = MAKELONG(pt.x, pt.y); m_ToolTip.Activate(TRUE); // make sure tooltip is active m_ToolTip.RelayEvent(&msg); // Let the ToolTip process this message. } else if ( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN ) { CWnd* pCurrent= GetFocus(); int ctrl = pCurrent->GetDlgCtrlID(); //if (ctrl == IDC_OPT_TEXT_GAIF) { //} else if (isCEditBox(ctrl)) { ::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 CGainPzPage::isCEditBox(int nID) { BOOL isEdit = FALSE; switch (nID) { case IDC_OPT_TEXT_RESL: isEdit = TRUE; break; case IDC_OPT_TEXT_INOF: isEdit = TRUE; break; case IDC_OPT_TEXT_GAIN: isEdit = TRUE; break; case IDC_OPT_TEXT_GAIF: isEdit = TRUE; break; case IDC_OPT_TEXT_PAPZ: isEdit = TRUE; break; } return isEdit; } BOOL CGainPzPage::isCComboBox(int nID) { BOOL isCombo = FALSE; switch (nID) { case IDC_OPT_COMBO_RESL: isCombo = TRUE; break; case IDC_OPT_COMBO_AINP: isCombo = TRUE; break; case IDC_OPT_COMBO_INOF: isCombo = TRUE; break; case IDC_OPT_COMBO_GAIA: isCombo = TRUE; break; case IDC_OPT_COMBO_PAPZ: isCombo = TRUE; break; } return isCombo; } void CGainPzPage::OnBnClickedButtonFineGainEnter() { CString strGAIF; double dblGAIF; GetDlgItem(IDC_OPT_TEXT_GAIF)->GetWindowText(strGAIF); if (strGAIF.GetLength() > 0) { dblGAIF = atof(strGAIF); if ((dblGAIF > dblGAIF_Max) || (dblGAIF < dblGAIF_Min)) { strGAIF = "1.000"; dblGAIF = 1.000; GetDlgItem(IDC_OPT_TEXT_GAIF)->SetWindowText(strGAIF); } } else { strGAIF = "1.000"; dblGAIF = 1.000; GetDlgItem(IDC_OPT_TEXT_GAIF)->SetWindowText(strGAIF); } UpdateGainValue(); // update gain value display } void CGainPzPage::OnCbnSelchangeOptComboGainSelect() { CComboBox* pCombo = (CComboBox*)GetDlgItem(IDC_OPT_COMBO_GAIN_SELECT); s.profile->SendCoarseFineGain = pCombo->GetCurSel(); } void CGainPzPage::OnBnClickedButtonCoarseFineToTotal() { CString strGain; double dblGain; // get coarse (analog) * fine gain from display label GetDlgItem(IDC_OPT_VALUE_GAIN)->GetWindowText(strGain); dblGain = atof(strGain); // test for total gain errors if (dblGain < DppGain.MinGain) { strGain.Format("%.2f",DppGain.MinGain); } else if (dblGain > DppGain.MaxGain) { strGain.Format("%.1f",DppGain.MaxGain); } GetDlgItem(IDC_OPT_TEXT_GAIN)->SetWindowText(strGain); } void CGainPzPage::OnBnClickedButtonTotalToCoarseFine() { CString strGain; CString strFine; CString strCoarse; CString strTotal; double dblGain; double prevGain, curGain; int idxGain; GetDlgItem(IDC_OPT_TEXT_GAIN)->GetWindowText(strGain); // get total gain // use dp5 algrorithm to split into coarse (analog) and fine gains dblGain = atof(strGain); if (dblGain < DppGain.MinGain) { dblGain = DppGain.MinGain; } else if (dblGain > DppGain.MaxGain) { dblGain = DppGain.MaxGain; } idxGain = 0; prevGain = fabs(dblGain - DppGain.ptrGainTable[0]); curGain = fabs(dblGain - DppGain.ptrGainTable[1]); while((prevGain > curGain) && (idxGain < (DppGain.GainTableCount - 1))) { idxGain++; prevGain = curGain; curGain = fabs(dblGain - DppGain.ptrGainTable[idxGain+1]); } curGain = dblGain / DppGain.ptrGainTable[idxGain]; // f = required fine gain, 1.15 fixed point //strGain.Format("Total In: %.3fx ",dblGain); //strCoarse.Format("Coarse: %.3fx ",DP5_Gain[idxGain]); //strFine.Format("Fine: %.4fx ",curGain); //strTotal.Format("Total Out: %.3fx ",(DP5_Gain[idxGain] * curGain)); //AfxMessageBox(strGain + strCoarse + strFine + strTotal); strFine.Format("%.3f",curGain); GetDlgItem(IDC_OPT_TEXT_GAIF)->SetWindowText(strFine); // set fine gain CComboBox* pCombo = (CComboBox*)GetDlgItem(IDC_OPT_COMBO_GAIA); pCombo->SetCurSel(idxGain); OnBnClickedButtonFineGainEnter(); UpdateOptComboGAIA(); // update display control OnCbnSelchangeOptComboGaia2(); // update text value } void CGainPzPage::OnCbnSelchangeOptComboGaia2() { CComboBox* pCombo = (CComboBox*)GetDlgItem(IDC_OPT_COMBO_GAIA); CComboBox* pCombo2 = (CComboBox*)GetDlgItem(IDC_OPT_COMBO_GAIA2); pCombo->SetCurSel(pCombo2->GetCurSel()); OnCbnSelchangeOptComboGaia(); } void CGainPzPage::UpdateOptComboGAIA() { CComboBox* pCombo = (CComboBox*)GetDlgItem(IDC_OPT_COMBO_GAIA); CComboBox* pCombo2 = (CComboBox*)GetDlgItem(IDC_OPT_COMBO_GAIA2); pCombo2->SetCurSel(pCombo->GetCurSel()); } // 25.6uS, 51.2uS, 102.4uS, 204.8uS, 409.6uS, 819.2uS, 1638.4uS, 3276.8uS // 102.4uS, 204.8uS, 409.6uS, 819.2uS, 1638.4uS, 3276.8uS, 6553.6uS, 13107.2uS void CGainPzPage::SetDetResetValues(int nID, BOOL is80MHz) { CComboBox* pCombo = (CComboBox*)GetDlgItem(nID); pCombo->ResetContent(); if (is80MHz) { //FPGA clock=80MHz pCombo->AddString("OFF"); pCombo->AddString("25.6"); pCombo->AddString("51.2"); pCombo->AddString("102.4"); pCombo->AddString("204.8"); pCombo->AddString("409.6"); pCombo->AddString("819.2"); pCombo->AddString("1638.4"); pCombo->AddString("3276.8"); } else { //FPGA clock=20MHz pCombo->AddString("OFF"); pCombo->AddString("102.4"); pCombo->AddString("204.8"); pCombo->AddString("409.6"); pCombo->AddString("819.2"); pCombo->AddString("1638.4"); pCombo->AddString("3276.8"); pCombo->AddString("6553.6"); pCombo->AddString("13107.2"); } } void CGainPzPage::InitCombo(HWND hDlg, DP5_CONFIGURATION cfg, int nID) { CString strVal = cfg.Setting; int idxList; CComboBox &cb = *(CComboBox *) GetDlgItem(nID); //idxList = s.CtrlUtil.FindCboIdx(hDlg,nID,strVal); idxList = s.CtrlUtil.FindCboIdxExact(hDlg,nID,strVal); // try exact first if (idxList == LB_ERR) { idxList = s.CtrlUtil.FindCboIdx(hDlg,nID,strVal); } if (idxList == LB_ERR) { // if (idxList != LB_ERR) we already found the value strVal = cfg.TextValue; if (strVal.Find('#') >= 0) { // try the text idxList = s.CtrlUtil.FindCboIdx(hDlg,nID,strVal); if (idxList == LB_ERR) { // not found default to 0 idxList = 0; } } else { idxList = 0; // set to first item } } cb.SetCurSel(idxList); } void CGainPzPage::OnCbnSelchangeOptComboResl2() { CString strRESL; CComboBox* pCombo = (CComboBox*)GetDlgItem(IDC_OPT_COMBO_RESL); CComboBox* pCombo2 = (CComboBox*)GetDlgItem(IDC_OPT_COMBO_RESL2); int iRESL = pCombo2->GetCurSel(); if (iRESL > 0) { //have value pCombo->SetCurSel(0); CboUpdate(dciRESL); pCombo2->GetWindowText(strRESL); TextUpdate(dciRESL); GetDlgItem(IDC_OPT_TEXT_RESL)->SetWindowText(strRESL); } else { // off pCombo->SetCurSel(1); CboUpdate(dciRESL); } } //s.DppConfig.bGammaRadHVMode; // GammaRad HV //s.DppConfig.bConfigHVPolarity; // Detector HV Polarity, for setup warnings //s.DppConfig.bPC5Detected; // PC5 connected,PX5 HV Pwr Error //s.DppConfig.bBootHVPolarity; // HV Polarity from status packet //s.DppConfig.bAnalogPolarity; // Analog Input Polarity, for setup warnings //m_PowerHvWarning==IDC_STATIC_HV_WARNING void CGainPzPage::SetHvPowerWarning() { CString strPolarity; CString strWarning; m_PowerHvWarning.ShowWindow(SW_HIDE); if (s.isDppConnected) { // disable warnings for px5 with HPGe option if ((s.profile->device_type == dppPX5) && (s.DP5Stat.m_DP5_Status.DPP_options == PX5_OPTION_HPGe_HVPS)) { return; } if (s.DppConfig.bPC5Detected) { if (s.DppConfig.bConfigHVPolarity == s.DppConfig.bAnalogPolarity) { m_PowerHvWarning.ShowWindow(SW_SHOW); strWarning = " Input and HV polarity \r incorrect for Amptek detectors"; if (s.DppConfig.bAnalogPolarity) { strPolarity = " \r BOTH + (POS)"; } else { strPolarity = " \r BOTH - (NEG)"; } m_PowerHvWarning.SetWindowText(strWarning + strPolarity); } else { m_PowerHvWarning.SetWindowText(""); } } else if (s.profile->device_type == dppPX5) { m_PowerHvWarning.ShowWindow(SW_SHOW); m_PowerHvWarning.SetWindowText("PX5 HV Power Error"); } else { // no pc5 or hv detected m_PowerHvWarning.SetWindowText(""); } } else { // not connected m_PowerHvWarning.SetWindowText(""); } } //////////////////////////////////////////////////////////////////////////////////// // HtmlHelp for shared dialog // NOTE: shared dialogs use string type IDD, not global IDD BOOL CGainPzPage::OnHelpInfo(HELPINFO* pHelpInfo) { CString strHelp; if (pHelpInfo->iContextType == HELPINFO_WINDOW) { if (pHelpInfo->dwContextId == 0) { ::HtmlHelp(this->GetSafeHwnd(), theApp.m_pszHelpFilePath, HH_HELP_CONTEXT, HIDD_GAINPZ_PAGE); } else { // } } return true; } void CGainPzPage::OnHelp() // enable property sheet help button help { ::HtmlHelp(this->GetSafeHwnd(), theApp.m_pszHelpFilePath, HH_HELP_CONTEXT, HIDD_GAINPZ_PAGE); //SendMessage(WM_COMMANDHELP); // } //////////////////////////////////////////////////////////////////////////////////// void CGainPzPage::BuildToolTips() { if (!m_ToolTip.Create(this)) { TRACE0("Unable to create ToolTip control\n"); } else { m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_AINP), IDS_TT_ANALOG_INPUT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_AINP), IDS_TT_ANALOG_INPUT); m_ToolTip.AddTool(GetDlgItem(IDC_BUTTON_TOTAL_TO_COARSE_FINE), IDS_TT_ARROWS); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_VALUE_GAIA), IDS_TT_COARSE_GAIN); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_GAIA), IDS_TT_COARSE_GAIN); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_GAIA), IDS_TT_COARSE_GAIN); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_GAIF), IDS_TT_FINE_GAIN); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_GAIF), IDS_TT_FINE_GAIN); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_GAIF), IDS_TT_FINE_GAIN); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_GAIF), IDS_TT_FINE_GAIN); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_GAIN), IDS_TT_TOTAL_GAIN); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_VALUE_GAIN), IDS_TT_TOTAL_GAIN); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_GAIN), IDS_TT_TOTAL_GAIN); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_GAIN), IDS_TT_TOTAL_GAIN); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_GAIN), IDS_TT_TOTAL_GAIN); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_INOF), IDS_TT_INPUT_OFFSET); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_INOF), IDS_TT_INPUT_OFFSET); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_INOF), IDS_TT_INPUT_OFFSET); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_INOF), IDS_TT_INPUT_OFFSET); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_INOF), IDS_TT_INPUT_OFFSET); //m_ToolTip.AddTool(GetDlgItem(IDC_STATIC_GAINPZ_PAGE), IDS_TT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_RESL), IDS_TT_RESET_LOCKOUT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_RESL), IDS_TT_RESET_LOCKOUT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_RESL), IDS_TT_RESET_LOCKOUT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_RESL), IDS_TT_RESET_LOCKOUT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_RESL), IDS_TT_RESET_LOCKOUT); //m_ToolTip.AddTool(GetDlgItem(IDC_STATIC_GAIN_ADVANCED), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_STATIC_GAIN_BASIC), IDS_TT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_GAIN_SELECT), IDS_TT_SEND_TOTAL_OR_COARSE_FINE_GAIN); m_ToolTip.AddTool(GetDlgItem(IDC_BUTTON_FINE_GAIN_ENTER), IDS_TT_FINE_GAIN); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_GAIA2), IDS_TT_COARSE_GAIN); //m_ToolTip.AddTool(GetDlgItem(IDC_STATIC_GAIN_STANDARD), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_STATIC_AVANCED_GAIN_CONTROL), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_RESL2), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_RESL2), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_RESL2), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_STATIC_HV_WARNING), IDS_TT); m_ToolTip.AddTool(GetDlgItem(IDC_BUTTON_COARSE_FINE_TO_TOTAL), IDS_TT_ARROWS); m_ToolTip.Activate(TRUE); m_ToolTip.SetMaxTipWidth(200); } }