#include "StdAfx.h" #include "SCommon.h" #include #include #include "MiscPageRes.h" #include "PowerPageRes.h" #include "ShapingPageRes.h" #include "FilePageRes.h" #include "GainPzPageRes.h" #include "McaPageRes.h" CSCommon::CSCommon(void) { profile = &profileCls; HaveConfig = FALSE; ReloadCfg = FALSE; FindCommand = FALSE; FindCtrlID = 0; plot = &m_plot; // point to CPlot class to operate like DppMCA spectraList.m_currentSpectrum = &m_Spectrum; // point to CSpectrum class to operate like DppMCA // seed random number generator srand((unsigned)time(NULL)); //Seed the random-number generator with current time } CSCommon::~CSCommon(void) { } CString CSCommon::Get(LPCTSTR profile, LPCTSTR entry, LPCTSTR def) { return(theApp.GetProfileString(profile, entry, def)); } int CSCommon::Get(LPCTSTR profile, LPCTSTR entry, int def) { return(theApp.GetProfileInt(profile, entry, def)); } BOOL CSCommon::Put(LPCTSTR profile, LPCTSTR entry, LPCTSTR def) { return(theApp.WriteProfileString(profile, entry, def)); } BOOL CSCommon::Put(LPCTSTR profile, LPCTSTR entry, int def) { return(theApp.WriteProfileInt(profile, entry, def)); } void CSCommon::LoadProfile() { GETP1(regDP5Comm, SCAEnabled, 0x00); GETP1(regDP5Comm, SockAddr, 0xFF00A8C0); GETP1(regDP5Comm, CurrentInterface, 0x01); GETP1(regDP5Comm, ComPort, 0x01); GETP1(regDP5Comm, baud_rate, 115200); // plot type GETP1(regDP5Comm, isScaleLog, FALSE); //TRUE=log, FALSE=linear, default=FALSE GETP1(regDP5Comm, isPlotLine, FALSE); //TRUE=line, FALSE=solid, default=FALSE } void CSCommon::SaveProfile() { CString regDP5Comm1 = regDP5Comm; // convert const to CString PUTP1(regDP5Comm1, SCAEnabled); PUTP1(regDP5Comm1, SockAddr); PUTP1(regDP5Comm1, CurrentInterface); PUTP1(regDP5Comm1, ComPort); PUTP1(regDP5Comm1, baud_rate); // plot type PUTP1(regDP5Comm1, isScaleLog); PUTP1(regDP5Comm1, isPlotLine); } void CSCommon::CreateDP5Cfg() { //DP5CfgCmd(DP5_CMD_INDEX idxDP5Cfg, // dp5 command index // CString Command, // 4-char COMMAND mnemonic // int ListCtrlID, // combobox control ID if any // int TextCtrlID, // text control ID if any // DP5_CTRL_TYPE CtrlType, // control type // DP5_CTRL_GROUP CtrlGroup, // control group (page) // CString Description, // COMMAND Description // CString Units) // COMMAND units DP5CfgCmd(dciRESC,"RESC",IDC_OPT_COMBO_RESC,0, dctCbo, dcgFile, "Reset Configuration", "", ""); DP5CfgCmd(dciRESL,"RESL",IDC_OPT_COMBO_RESL,IDC_OPT_TEXT_RESL, dctCboTxt, dcgGainPZ, "Reset Lockout", "uS", "0 to 65535uS"); DP5CfgCmd(dciAINP,"AINP",IDC_OPT_COMBO_AINP,0, dctCbo, dcgGainPZ, "Analog Input Pos/Neg", "", ""); DP5CfgCmd(dciINOF,"INOF",IDC_OPT_COMBO_INOF,IDC_OPT_TEXT_INOF, dctCboTxt, dcgGainPZ, "Input Offset", "mV", "-2047 to +2047mV"); DP5CfgCmd(dciGAIN,"GAIN",0, IDC_OPT_TEXT_GAIN, dctTxt, dcgGainPZ, "Total Gain (Analog * Fine)", "x", "0.75 to 150"); DP5CfgCmd(dciMCAS,"MCAS",IDC_OPT_COMBO_MCAS,0, dctCbo, dcgMCA, "MCA Source", "", ""); DP5CfgCmd(dciTHSL,"THSL",0, IDC_OPT_TEXT_THSL, dctTxt, dcgMCA, "Slow Threshhold", "%", "0 to 24.9% with 8 to bit precision (256 => 25%)"); DP5CfgCmd(dciMCAE,"MCAE",IDC_OPT_COMBO_MCAE,0, dctCbo, dcgMCA, "MCA Enable", "", ""); DP5CfgCmd(dciMCAC,"MCAC",IDC_OPT_COMBO_MCAC,0, dctCbo, dcgMCA, "MCA/MCS Channels", "", ""); DP5CfgCmd(dciGATE,"GATE",IDC_OPT_COMBO_GATE,0, dctCbo, dcgMCA, "Gate Control", "", ""); DP5CfgCmd(dciPRET,"PRET",IDC_OPT_COMBO_PRET,IDC_OPT_TEXT_PRET, dctCboTxt, dcgMCA, "Preset Acquisition Time", "S", "0-1677721.5 S"); DP5CfgCmd(dciPREC,"PREC",IDC_OPT_COMBO_PREC,IDC_OPT_TEXT_PREC, dctCboTxt, dcgMCA, "Preset Counts", "cnts", "0-4294967295"); DP5CfgCmd(dciMCST,"MCST",0, IDC_OPT_TEXT_MCST, dctTxt, dcgMCA, "MCS Timebase", "S", "multiples of 10mS; up to 655.35S"); DP5CfgCmd(dciSOFF,"SOFF",IDC_OPT_COMBO_SOFF,IDC_OPT_TEXT_SOFF, dctCboTxt, dcgMCA, "Set Spectrum Offset", "CH", "+/- Channels. +0.25=+1/4 channel (higher energy)"); DP5CfgCmd(dciDACF,"DACF",0, IDC_OPT_TEXT_DACF, dctTxt, dcgMisc, "DAC Offset", "mV", "-500 to +499mV"); DP5CfgCmd(dciDACO,"DACO",IDC_OPT_COMBO_DACO,IDC_OPT_TEXT_DACO, dctCboTxt, dcgMisc, "DAC Output", "", "1 to 8"); DP5CfgCmd(dciSCOE,"SCOE",IDC_OPT_COMBO_SCOE,0, dctCbo, dcgMisc, "Scope Trigger Edge", "", ""); DP5CfgCmd(dciAUO1,"AUO1",IDC_OPT_COMBO_AUO1,IDC_OPT_TEXT_AUO1, dctCboTxt, dcgMisc, "AUX_OUT Selection", "", "1 to 8"); DP5CfgCmd(dciSCOT,"SCOT",IDC_OPT_COMBO_SCOT,0, dctCbo, dcgMisc, "Scope Trigger Position", "%", ""); DP5CfgCmd(dciGPED,"GPED",IDC_OPT_COMBO_GPED,0, dctCbo, dcgMisc, "G.P. Counter Edge", "", ""); DP5CfgCmd(dciGPIN,"GPIN",IDC_OPT_COMBO_GPIN,IDC_OPT_TEXT_GPIN, dctCboTxt, dcgMisc, "G.P. Counter Input", "", "1 to 8"); DP5CfgCmd(dciTPMO,"TPMO",IDC_OPT_COMBO_TPMO,0, dctCbo, dcgMisc, "Test Pulser On/Off", "", ""); DP5CfgCmd(dciGPME,"GPME",IDC_OPT_COMBO_GPME,0, dctCbo, dcgMisc, "G.P. Counter Uses MCA_EN?", "", ""); DP5CfgCmd(dciGPGA,"GPGA",IDC_OPT_COMBO_GPGA,0, dctCbo, dcgMisc, "G.P. Counter Uses GATE?", "", ""); DP5CfgCmd(dciGPMC,"GPMC",IDC_OPT_COMBO_GPMC,0, dctCbo, dcgMisc, "G.P. counter Cleared With MCA Counters?", "", ""); DP5CfgCmd(dciPAPS,"PAPS",IDC_OPT_COMBO_PAPS,0, dctCbo, dcgPower, "PreAmp 8.5/5 (N/A)", "V", ""); DP5CfgCmd(dciHVSE,"HVSE",IDC_OPT_COMBO_HVSE,IDC_OPT_TEXT_HVSE, dctCboTxt, dcgPower, "HV Set", "V", "0 to 1500V (+HV) or 0 to -1500V (-HV)"); DP5CfgCmd(dciTECS,"TECS",IDC_OPT_COMBO_TECS,IDC_OPT_TEXT_TECS, dctCboTxt, dcgPower, "TEC Set", "K", "0 to 299K"); DP5CfgCmd(dciPAPZ,"PAPZ",IDC_OPT_COMBO_PAPZ,IDC_OPT_TEXT_PAPZ, dctCboTxt, dcgPower, "Pole-Zero", "uS", "34.5uS to 8773uS"); DP5CfgCmd(dciCLCK,"CLCK",IDC_OPT_COMBO_CLCK,0, dctCbo, dcgShaping, "20MHz/80MHz", "", ""); DP5CfgCmd(dciTFLA,"TFLA",0, IDC_OPT_TEXT_TFLA, dctTxt, dcgShaping, "Flat Top", "uS", "0 to 51.2uS"); DP5CfgCmd(dciTHFA,"THFA",0, IDC_OPT_TEXT_THFA, dctTxt, dcgShaping, "Fast Threshold", "", "0 to 255.93"); DP5CfgCmd(dciPURE,"PURE",IDC_OPT_COMBO_PURE,IDC_OPT_TEXT_PURE, dctCboTxt, dcgShaping, "PUR Interval On/Off", "uS", ""); DP5CfgCmd(dciSCTC,"SCTC",IDC_OPT_COMBO_SCTC,IDC_OPT_TEXT_SCTC, dctCboTxt, dcgShaping, "Scintillator Time Constant", "nS", ""); DP5CfgCmd(dciTPEA,"TPEA",0, IDC_OPT_TEXT_TPEA, dctTxt, dcgShaping, "Peaking Time", "uS", "0.8-102.4uS (CLK=20MHz); 0.2-25.6uS (80MHz); 0.2-102.4uS (AUTO)"); DP5CfgCmd(dciRTDS,"RTDS",0, IDC_OPT_TEXT_RTDS, dctTxt, dcgShaping, "RTD Sensitivity", "%", "0 to 398"); DP5CfgCmd(dciRTDE,"RTDE",IDC_OPT_COMBO_RTDE,0, dctCbo, dcgShaping, "RTD On/Off", "", ""); DP5CfgCmd(dciRTDT,"RTDT",0, IDC_OPT_TEXT_RTDT, dctTxt, dcgShaping, "RTD Threshold", "%", "0 to 49.9"); DP5CfgCmd(dciBLRD,"BLRD",0, IDC_OPT_TEXT_BLRD, dctTxt, dcgShaping, "BLR Down Correction", "", "0 to 3"); DP5CfgCmd(dciBLRU,"BLRU",0, IDC_OPT_TEXT_BLRU, dctTxt, dcgShaping, "BLR Up Correction", "", "0 to 3"); DP5CfgCmd(dciBLRM,"BLRM",IDC_OPT_COMBO_BLRM,0, dctCbo, dcgShaping, "BLR Mode", "", ""); DP5CfgCmd(dciPDMD,"PDMD",IDC_OPT_COMBO_PDMD,0, dctCbo, dcgMCA, "Peak Detect Mode (Min/Max)", "", ""); DP5CfgCmd(dciCUSP,"CUSP",IDC_OPT_COMBO_CUSP,IDC_OPT_TEXT_CUSP, dctCboTxt, dcgShaping, "Non-Trapezoidal Shaping", "%", "-99 to +99%"); //======================================================================================================================== DP5CfgCmd(dciAUO2,"AUO2",IDC_OPT_COMBO_AUO2,IDC_OPT_TEXT_AUO2, dctCboTxt, dcgMisc,"AUX_OUT2 Selection", "", "1-8"); DP5CfgCmd(dciBOOT,"BOOT",IDC_OPT_COMBO_BOOT,0, dctCbo, dcgPower, "PC5 On At StartUp", "", ""); //======================================================================================================================== DP5CfgCmd(dciGAIA,"GAIA",IDC_OPT_COMBO_GAIA,0, dctCbo, dcgGainPZ, "Coarse Gain", "", ""); DP5CfgCmd(dciGAIF,"GAIF",0, IDC_OPT_TEXT_GAIF, dctTxt, dcgGainPZ, "Fine Gain", "x", "0.750-1.250"); //======================================================================================================================== //======================================================================================================================== //======================================================================================================================== DP5CfgCmd(dciMCSL,"MCSL",0, IDC_OPT_TEXT_MCSL, dctTxt, dcgMCA, "MCS Low Channel", "", "1-8192"); DP5CfgCmd(dciMCSH,"MCSH",0, IDC_OPT_TEXT_MCSH, dctTxt, dcgMCA, "MCS High Channel", "", "1-8192"); DP5CfgCmd(dciPRCL,"PRCL",0, IDC_OPT_TEXT_PRCL, dctTxt, dcgMCA, "Preset Count Low Channel", "", "1-8192"); DP5CfgCmd(dciPRCH,"PRCH",0, IDC_OPT_TEXT_PRCH, dctTxt, dcgMCA, "Preset Count High Channel", "", "1-8192"); DP5CfgCmd(dciPRER,"PRER",IDC_OPT_COMBO_PRER,IDC_OPT_TEXT_PRER, dctCboTxt, dcgMCA, "Preset Real Time", "S", "0-4294967.29"); DP5CfgCmd(dciTLLD,"TLLD",IDC_OPT_COMBO_TLLD,IDC_OPT_TEXT_TLLD, dctCboTxt, dcgMCA, "Low Level Discriminator", "CH", "1-8192"); DP5CfgCmd(dciSCOG,"SCOG",IDC_OPT_COMBO_SCOG,0, dctCbo, dcgMisc, "Gain", "", ""); DP5CfgCmd(dciTPFA,"TPFA",IDC_OPT_COMBO_TPFA,0, dctCbo, dcgShaping, "Fast Peaking Time", "", ""); DP5CfgCmd(dciVOLU,"VOLU",IDC_OPT_COMBO_VOLU,0, dctCbo, dcgMisc, "Speaker On/Off", "", ""); DP5CfgCmd(dciCON1,"CON1",IDC_OPT_COMBO_CON1,0, dctCbo, dcgMisc, "Connector 1", "", ""); DP5CfgCmd(dciCON2,"CON2",IDC_OPT_COMBO_CON2,0, dctCbo, dcgMisc, "Connector 1", "", ""); } // Configuration Dialog Update Notes: // 1. Control Resources // [] For ComboText Group Add cbo,txt,units,limits,frame controls // [] For Combo Only Add cbo, frame // [] For Text Only, Add txt,units,limits,frame // [] For All Combo Add data resource string (item1;item2;...) // [] For ALL Add name of control to frame // 2. Initialization // [] For ALL Controls Add InitDlgItem at InitControls // [] For Text Add Entry in InitDlgItem // [] For ALL Combo Add CboUpdate at InitControls // [] For ComboText Group Add Text Update Entry in CboUpdate // 3. Control Command Handlers // [] Text TextUpdate Command Handler // [] Cbo CboUpdate Command Handler // [] ComboText Group, TextUpdate and CboUpdate // 4. ComboText Group Text Edit Function // [] CboTextVis bonds Combo with Text for CboTxt Single Control Function // [] Add CboTextVis to Text Update Entry in CboUpdate // 5. CDialog Trap Key Updates // [] VK_RETURN is trapped to prevent dialog closing during edits (MS Defaults Bug) // [] PreTranslateMessage traps Combo/Text control VK_RETURN, tabs to next stop // [] For Text Add nID to isCEditBox // [] For Combo Add nID to isCComboBox // ==== Text Only Summary ==== // [] Add txt,units,limits,frame // [] Add name of control to frame // [] Add InitDlgItem at InitControls // [] Add Text Update Entry in InitDlgItem // [] TextUpdate Command Handler // [] Add nID to isCEditBox // ==== Combo Only Summary ==== // [] Add cbo, frame // [] Add name of control to frame // [] Add data resource string // [] Add InitDlgItem at InitControls // [] Add CboUpdate at InitControls // [] CboUpdate Command Handler // [] Add nID to isCComboBox // ==== ComboText Group Summary ==== // [] Add cbo,txt,units,limits,frame controls // [] Add name of control to frame // [] Add data resource string // [] Add InitDlgItem at InitControls // [] Add CboUpdate at InitControls // [] Add Text Update Entry in InitDlgItem // [] Add Text Update Entry in CboUpdate // [] Add CboTextVis to Text Update Entry in CboUpdate // [] TextUpdate Command Handler // [] CboUpdate Command Handler // [] Add nID Txt to isCEditBox // [] Add nID Cbo to isCComboBox void CSCommon::DP5CfgCmd(DP5_CMD_INDEX idxDP5Cfg, // dp5 command index CString Command, // 4-char COMMAND mnemonic int ListCtrlID, // combobox control ID if any int TextCtrlID, // text control ID if any DP5_CTRL_TYPE CtrlType, // control type DP5_CTRL_GROUP CtrlGroup, // control group (page) CString Description, // COMMAND Description CString Units, // COMMAND units CString Limits) { // set constant values m_DP5Cfg[idxDP5Cfg].Command = Command; m_DP5Cfg[idxDP5Cfg].ListCtrlID = ListCtrlID; m_DP5Cfg[idxDP5Cfg].TextCtrlID = TextCtrlID; m_DP5Cfg[idxDP5Cfg].CtrlType = CtrlType; m_DP5Cfg[idxDP5Cfg].CtrlGroup = CtrlGroup; m_DP5Cfg[idxDP5Cfg].Description = Description; m_DP5Cfg[idxDP5Cfg].Units = Units; m_DP5Cfg[idxDP5Cfg].Limits = Limits; // initialize dynamic values m_DP5Cfg[idxDP5Cfg].Setting = ""; m_DP5Cfg[idxDP5Cfg].TextValue = ""; m_DP5Cfg[idxDP5Cfg].ComboValue = ""; m_DP5Cfg[idxDP5Cfg].ComboIndex = -1; m_DP5Cfg[idxDP5Cfg].Comments = ""; m_DP5Cfg[idxDP5Cfg].ValComments = ""; m_DP5Cfg[idxDP5Cfg].bAppendUnits = FALSE; }