#include "StdAfx.h" #include "DppGain.h" // DP5/PX5/DP5G Analog Gain CDppGain::CDppGain(void) { GainTable = dagtDP5; } CDppGain::~CDppGain(void) { // } int CDppGain::GetGainCount(DppAGainTable GainTable) { int GainCount = 0; if (GainTable == dagtDP5) { GainCount = DP5_GAIN_COUNT; } else if (GainTable == dagtPX5) { GainCount = PX5_GAIN_COUNT; } else if (GainTable == dagtDP5G) { GainCount = DP5G_GAIN_COUNT; } else if (GainTable == dagtMCA8000D) { GainCount = MCA8000D_GAIN_COUNT; } else if (GainTable == dagtTB5) { GainCount = DP5G_GAIN_COUNT; } else if (GainTable == dagtDP5Dx) { GainCount = DP5_DX_GAIN_COUNT; } else if (GainTable == dagtDP5X) { GainCount = DP5X_GAIN_COUNT; } return GainCount; } CString CDppGain::GetTotalGainLimitsLabel(DppAGainTable GainTable) { CString GainLabel(""); if (GainTable == dagtDP5) { GainLabel = "0.75 to 150"; } else if (GainTable == dagtPX5) { GainLabel = "0.75 to 500"; } else if (GainTable == dagtDP5G) { GainLabel = "1.0 to 10.0"; } else if (GainTable == dagtMCA8000D) { GainLabel = "1x OR 10x"; } else if (GainTable == dagtTB5) { GainLabel = "1.0 to 10.0"; } else if (GainTable == dagtDP5Dx) { GainLabel = "0.75 to 250"; } else if (GainTable == dagtDP5X) { GainLabel = "3.00 to 150"; } return GainLabel; } double CDppGain::GetTotalGainLimitsMin(DppAGainTable GainTable) { double GainMin = 0.75; if (GainTable == dagtDP5) { GainMin = 0.75; } else if (GainTable == dagtPX5) { GainMin = 0.75; } else if (GainTable == dagtDP5G) { GainMin = 1.0; } else if (GainTable == dagtMCA8000D) { GainMin = 1; } else if (GainTable == dagtTB5) { GainMin = 1.0; } else if (GainTable == dagtDP5Dx) { GainMin = 0.75; } else if (GainTable == dagtDP5X) { GainMin = 3.0; } return GainMin; } double CDppGain::GetTotalGainLimitsMax(DppAGainTable GainTable) { double GainMax = 150; if (GainTable == dagtDP5) { GainMax = 150; } else if (GainTable == dagtPX5) { GainMax = 500; } else if (GainTable == dagtDP5G) { GainMax = 10.0; } else if (GainTable == dagtMCA8000D) { GainMax = 10; } else if (GainTable == dagtTB5) { GainMax = 10.0; } else if (GainTable == dagtDP5Dx) { GainMax = 250; } else if (GainTable == dagtDP5X) { GainMax = 150; } return GainMax; } BOOL CDppGain::isInTotalGainRange(CString strTotalGain, DppAGainTable GainTable) { double GainMin = 0.75; double GainMax = 150; BOOL inRange = FALSE; double dblGain = 0.75; dblGain = atof(strTotalGain); GainMin = GetTotalGainLimitsMin(GainTable); GainMax = GetTotalGainLimitsMax(GainTable); if ((dblGain >= GainMin) && (dblGain <= GainMax)) { inRange = TRUE; } return inRange; } CString CDppGain::FixTotalGainRange(CString strTotalGain, DppAGainTable GainTable) { double GainMin = 0.75; double GainMax = 150; BOOL inRange = FALSE; double dblGain = 0.75; CString strGain; dblGain = atof(strTotalGain); strGain = strTotalGain; GainMin = GetTotalGainLimitsMin(GainTable); GainMax = GetTotalGainLimitsMax(GainTable); if ((dblGain >= GainMin) && (dblGain <= GainMax)) { strGain.Format("%.1f",dblGain); // value in range return value } else if (dblGain < GainMin) { dblGain = GainMin; strGain.Format("%.2f",dblGain); } else if (dblGain > GainMax) { dblGain = GainMax; strGain.Format("%.1f",dblGain); } return strGain; } double * CDppGain::GetGainTablePtr(DppAGainTable GainTable) { double * ptrGainTable; if (GainTable == dagtDP5) { ptrGainTable = &DP5_Gain[0]; } else if (GainTable == dagtPX5) { ptrGainTable = &PX5_Gain[0]; } else if (GainTable == dagtDP5G) { ptrGainTable = &DP5G_Gain[0]; } else if (GainTable == dagtMCA8000D) { ptrGainTable = &MCA8000D_Gain[0]; } else if (GainTable == dagtTB5) { ptrGainTable = &DP5G_Gain[0]; } else if (GainTable == dagtDP5Dx) { ptrGainTable = &DP5_DX_Gain[0]; } else if (GainTable == dagtDP5X) { ptrGainTable = &DP5X_Gain[0]; } return ptrGainTable; } void CDppGain::LoadGainTableValues(CComboBox *m_CoarseGain, DppAGainTable GainTable) { int GainCount = GetGainCount(GainTable); double * ptrGainTable = GetGainTablePtr(GainTable); CString strGain; int idxGain; double dblGain; m_CoarseGain->ResetContent(); for (idxGain=0;idxGainAddString(strGain); } m_CoarseGain->SetCurSel(0); } void CDppGain::LoadGainTableIndexes(CComboBox *m_CoarseGain, DppAGainTable GainTable) { int GainCount = GetGainCount(GainTable); CString strGain; int idxGain; m_CoarseGain->ResetContent(); for (idxGain=1;idxGain<=GainCount;idxGain++){ strGain.Format("%d",idxGain); m_CoarseGain->AddString(strGain); } m_CoarseGain->SetCurSel(0); } double CDppGain::FixTotalGainRangeDbl(double dblTotalGain, DppAGainTable GainTable) { double GainMin = 0.75; double GainMax = 150; BOOL inRange = FALSE; double dblGain = 0.75; dblGain = dblTotalGain; GainMin = GetTotalGainLimitsMin(GainTable); GainMax = GetTotalGainLimitsMax(GainTable); if ((dblGain >= GainMin) && (dblGain <= GainMax)) { // value in range return value } else if (dblGain < GainMin) { dblGain = GainMin; } else if (dblGain > GainMax) { dblGain = GainMax; } return dblGain; }