#pragma once #include "stdafx.h" // DP5 Dialog Helper Macros #define TEXT_VIS(cmd, en) GetDlgItem(IDC_OPT_TEXT_##cmd)->ShowWindow(en) #define UNIT_VIS(cmd, en) GetDlgItem(IDC_OPT_UNITS_##cmd)->ShowWindow(en) #define LIMIT_VIS(cmd, en) GetDlgItem(IDC_OPT_LIMITS_##cmd)->ShowWindow(en) #define ALL_VIS(cmd, en) TEXT_VIS(cmd, en);UNIT_VIS(cmd, en);LIMIT_VIS(cmd, en) #define UNIT_INIT(cmd, en) GetDlgItem(IDC_OPT_UNITS_##cmd)->SetWindowText(en) #define LIMIT_INIT(cmd, en) GetDlgItem(IDC_OPT_LIMITS_##cmd)->SetWindowText(en) #define CBO_TEXT_VIS(cmd, en) CboTextVis(IDC_OPT_COMBO_##cmd,IDC_OPT_TEXT_##cmd,en); #define HasComboCtrl 0x1 #define HasTextCtrl 0x2 // DP5_CMD_INDEX is the Master Index for ASCII commands. // DP5_CMD_INDEX orders the list of DP5 FW6 device commands in the correct order // For configuration commands to register properly order based on dependencies // must be maintained. typedef enum _DP5_CMD_INDEX { dciRESC, dciCLCK, dciTPEA, dciGAIF, dciGAIN, dciRESL, dciTFLA, dciTPFA, dciPURE, dciSCTC, dciRTDE, dciMCAS, dciMCAC, dciSOFF, dciAINP, dciINOF, dciGAIA, dciCUSP, dciPDMD, dciTHSL, dciTLLD, dciTHFA, dciDACO, dciDACF, dciRTDS, dciRTDT, dciBLRM, dciBLRD, dciBLRU, dciGATE, dciAUO1, dciPRET, dciPRER, dciPREL, dciPREC, dciPRCL, dciPRCH, dciHVSE, dciTECS, dciPAPZ, dciPAPS, dciSCOE, dciSCOT, dciSCOG, dciMCSL, dciMCSH, dciMCST, dciAUO2, dciTPMO, dciGPED, dciGPIN, dciGPME, dciGPGA, dciGPMC, dciMCAE, dciVOLU, dciCON1, dciCON2, dciBOOT //dciLAST // this does not exist } DP5_CMD_INDEX; #define DP5_CMD_MIN dciRESC #define DP5_CMD_MAX dciBOOT typedef enum _DP5_CTRL_TYPE { // dp5 command control type dctNone, // no controls dctCbo, // combobox only dctTxt, // text edit only dctCboTxt // combobox with text edit } DP5_CTRL_TYPE; typedef enum _DP5_CTRL_GROUP { // dp5 control group dcgFile, // file dcgMCA, // mca dcgShaping, // Shaping dcgGainPZ, // GainPZ dcgPower, // Power dcgMisc, // Misc dcgBootOpt // BootOpt } DP5_CTRL_GROUP; typedef enum _DP5_DATA_ID { // dp5 data id, index to dp5 config data ddiCommand, // 4-char COMMAND mnemonic ddiListCtrlID, // combobox control ID if any ddiTextCtrlID, // text control ID if any ddiCtrlType, // control type ddiCtrlGroup, // control group (page) ddiDescription, // COMMAND Description ddiUnits, // COMMAND units ddiTextValue, // typed-in text value ddiComboValue, // selected combo value text ddiComboIndex, // selected combo index ddiComments // to append to command on save } DP5_DATA_ID; typedef struct _DP5_CONFIGURATION { // these values are constant 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; // COMMAND limits // these values are read in CString Setting; // raw setting before parsing for controls CString TextValue; // typed-in text value CString ComboValue; // selected combo value text int ComboIndex; // selected combo index CString Comments; // to append to command on save CString ValComments; // to append to values on save BOOL bAppendUnits; // append optional units for typed-in values //BOOL bSendCommand; // command selected to be sent from dialog //int ControlOrder; } DP5_CONFIGURATION; #define MAX_DP5_CONFIGURATIONS 100 class CDP5ControlUtil { public: CDP5ControlUtil(void); ~CDP5ControlUtil(void); BOOL LoadingCfg; CString strFindTab; CString strFindCtrl; CString strFindIdx; int FindCboIdxExact(HWND hDlg, int cboDP5CtrlID, CString strVal); int FindCboIdx(HWND hDlg, int cboDP5CtrlID, CString strVal); //void SetCboIdxByStr(HWND hDlg, int cboDP5CtrlID, CString strVal); void SetCboIdxByStr(HWND hDlg, DP5_CONFIGURATION cfg); int FindUnitsInString(CString strValue, CString strUnits); void RemoveUnitsFromDecString(DP5_CONFIGURATION *cfg); CString AppendUnitsToString(CString strValue, CString strUnits); void AppendUnitsToSettingString(DP5_CONFIGURATION *cfg); void UpdateSetting(DP5_CONFIGURATION *cfg); void UpdateSettingOsc(DP5_CONFIGURATION *cfg); int OrderOut(int IndexIn); BOOL IsAllNumericString(CString strValue); CString GetValueWithUnitsString(DP5_CONFIGURATION cfg); };