// ChannelSettigDlg.cpp : implementation file
//

#include "stdafx.h"
#include "CollectionConditions.h"
#include "ChannelSettigDlg.h"
#include "afxdialogex.h"
#include "clogger_api.h"


// ChannelSettigDlg dialog

IMPLEMENT_DYNAMIC(ChannelSettigDlg, CDialogEx)

ChannelSettigDlg::ChannelSettigDlg(CWnd* pParent /*=NULL*/)
	: CDialogEx(IDD_CHANNELSETTING, pParent)
{

}

ChannelSettigDlg::~ChannelSettigDlg()
{
}

void ChannelSettigDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_COMBO_HWCH1, m_combo_hwch1);
	DDX_Control(pDX, IDC_COMBO_HWCH2, m_combo_hwch2);
	DDX_Control(pDX, IDC_COMBO_HWCH3, m_combo_hwch3);
	DDX_Control(pDX, IDC_COMBO_HWCH4, m_combo_hwch4);
	DDX_Control(pDX, IDC_COMBO_RANGE1, m_combo_range1);
	DDX_Control(pDX, IDC_COMBO_RANGE2, m_combo_range2);
	DDX_Control(pDX, IDC_COMBO_RANGE3, m_combo_range3);
	DDX_Control(pDX, IDC_COMBO_RANGE4, m_combo_range4);
	DDX_Control(pDX, IDC_COMBO_SCALEENABLE1, m_combo_scale_enable1);
	DDX_Control(pDX, IDC_COMBO_SCALEENABLE2, m_combo_scale_enable2);
	DDX_Control(pDX, IDC_COMBO_SCALEENABLE3, m_combo_scale_enable3);
	DDX_Control(pDX, IDC_COMBO_SCALEENABLE4, m_combo_scale_enable4);
	DDX_Control(pDX, IDC_EDIT_CHNAME1, m_edit_ch_name1);
	DDX_Control(pDX, IDC_EDIT_CHNAME2, m_edit_ch_name2);
	DDX_Control(pDX, IDC_EDIT_CHNAME3, m_edit_ch_name3);
	DDX_Control(pDX, IDC_EDIT_CHNAME4, m_edit_ch_name4);
	DDX_Control(pDX, IDC_EDIT_MAXDATA1, m_edit_max_data1);
	DDX_Control(pDX, IDC_EDIT_MAXDATA2, m_edit_max_data2);
	DDX_Control(pDX, IDC_EDIT_MAXDATA3, m_edit_max_data3);
	DDX_Control(pDX, IDC_EDIT_MAXDATA4, m_edit_max_data4);
	DDX_Control(pDX, IDC_EDIT_MAXSCALE1, m_edit_max_scale1);
	DDX_Control(pDX, IDC_EDIT_MAXSCALE2, m_edit_max_scale2);
	DDX_Control(pDX, IDC_EDIT_MAXSCALE3, m_edit_max_scale3);
	DDX_Control(pDX, IDC_EDIT_MAXSCALE4, m_edit_max_scale4);
	DDX_Control(pDX, IDC_EDIT_MINDATA1, m_edit_min_data1);
	DDX_Control(pDX, IDC_EDIT_MINDATA2, m_edit_min_data2);
	DDX_Control(pDX, IDC_EDIT_MINDATA3, m_edit_min_data3);
	DDX_Control(pDX, IDC_EDIT_MINDATA4, m_edit_min_data4);
	DDX_Control(pDX, IDC_EDIT_MINSCALE1, m_edit_min_scale1);
	DDX_Control(pDX, IDC_EDIT_MINSCALE2, m_edit_min_scale2);
	DDX_Control(pDX, IDC_EDIT_MINSCALE3, m_edit_min_scale3);
	DDX_Control(pDX, IDC_EDIT_MINSCALE4, m_edit_min_scale4);
	DDX_Control(pDX, IDC_COMBO_AICHANNELS, m_combo_ai_channels);
	DDX_Control(pDX, IDC_COMBO_INPUTTYPE, m_combo_inputtype);
}

//----------------------------------------
// Declaration of global variables
//----------------------------------------
short	g_ai_range[] = {	PM10,			// -10 to 10V
							PM5,			// -5 to 5V
							PM25,			// -2.5 to 2.5V
							PM125,			// -1.25 to 1.25V
							P10,			// 0 to 10V
							P5,				// 0 to 5V
							P25,			// 0 to 2.5V
							P125,			// 0 to 1.25V
							P20MA,			// 0 to 20mA
							P4TO20MA,		// 4 to 20mA
							PM20MA,			// -20 to 20mA
							P1TO5 };		// 1 to 5V

//----------------------------------------
// Data transfer
//----------------------------------------
void ChannelSettigDlg::channel_data(
	PCHANNEL_SETTING chennel_setting){
	m_channel_setting = chennel_setting;
}


BEGIN_MESSAGE_MAP(ChannelSettigDlg, CDialogEx)
	ON_BN_CLICKED(IDOK, &ChannelSettigDlg::OnBnClickedOk)
	ON_CBN_SELCHANGE(IDC_COMBO_AICHANNELS, &ChannelSettigDlg::OnCbnSelchangeComboAichannels)
	ON_CBN_SELCHANGE(IDC_COMBO_INPUTTYPE, &ChannelSettigDlg::OnCbnSelchangeComboInputtype)
	ON_CBN_SELCHANGE(IDC_COMBO_SCALEENABLE1, &ChannelSettigDlg::OnCbnSelchangeComboScaleenable1)
	ON_CBN_SELCHANGE(IDC_COMBO_SCALEENABLE2, &ChannelSettigDlg::OnCbnSelchangeComboScaleenable2)
	ON_CBN_SELCHANGE(IDC_COMBO_SCALEENABLE3, &ChannelSettigDlg::OnCbnSelchangeComboScaleenable3)
	ON_CBN_SELCHANGE(IDC_COMBO_SCALEENABLE4, &ChannelSettigDlg::OnCbnSelchangeComboScaleenable4)
END_MESSAGE_MAP()


// ChannelSettigDlg message handlers


//================================================================================
// Initialization setting
//================================================================================
BOOL ChannelSettigDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	CString		text_temp;			// For temporary text storage
	TCHAR		temp[256];			// For temporary storage
	int			i,j;				// Loop count
	int			ai_range_index;		// Analog input range index

	//----------------------------------------
	// Create the combobox for input method
	//----------------------------------------
	m_combo_inputtype.AddString(_T("Single-end input"));
	m_combo_inputtype.AddString(_T("Differential input"));
	//----------------------------------------
	// Update the selection of input method combobox
	//----------------------------------------
	m_combo_inputtype.SetCurSel(m_channel_setting->InputType);
	//----------------------------------------
	// Create the combobox for number of channles
	//----------------------------------------
	m_combo_ai_channels.AddString(_T("1"));
	m_combo_ai_channels.AddString(_T("2"));
	//----------------------------------------
	// For single-end input
	//----------------------------------------
	if(m_channel_setting->InputType == 0){
		m_combo_ai_channels.AddString(_T("3"));
		m_combo_ai_channels.AddString(_T("4"));
	}
	//----------------------------------------
	// Update the selection of the number of channels combobox (Number of channels - 1)
	//----------------------------------------
	if(m_channel_setting->AiChannels > 0){
		m_combo_ai_channels.SetCurSel(m_channel_setting->AiChannels - 1);
	}else{
		m_combo_ai_channels.SetCurSel(0);
	}
	for(i = 0; i < SEQUENCE_NUM;i++){
		//----------------------------------------
		// Initialize pointer array
		//----------------------------------------
		switch (i){
		case 0:
			m_pHwch[i] = &m_combo_hwch1;
			m_pRange[i] = &m_combo_range1;
			m_pChname[i] = &m_edit_ch_name1;
			m_pMindata[i] = &m_edit_min_data1;
			m_pMaxdata[i] = &m_edit_max_data1;
			m_pMinscale[i] = &m_edit_min_scale1;
			m_pMaxscale[i] = &m_edit_max_scale1;
			m_pScale_enable[i] = &m_combo_scale_enable1;
			break;
		case 1:
			m_pHwch[i] = &m_combo_hwch2;
			m_pRange[i] = &m_combo_range2;
			m_pChname[i] = &m_edit_ch_name2;
			m_pMindata[i] = &m_edit_min_data2;
			m_pMaxdata[i] = &m_edit_max_data2;
			m_pMinscale[i] = &m_edit_min_scale2;
			m_pMaxscale[i] = &m_edit_max_scale2;
			m_pScale_enable[i] = &m_combo_scale_enable2;
			break;
		case 2:
			m_pHwch[i] = &m_combo_hwch3;
			m_pRange[i] = &m_combo_range3;
			m_pChname[i] = &m_edit_ch_name3;
			m_pMindata[i] = &m_edit_min_data3;
			m_pMaxdata[i] = &m_edit_max_data3;
			m_pMinscale[i] = &m_edit_min_scale3;
			m_pMaxscale[i] = &m_edit_max_scale3;
			m_pScale_enable[i] = &m_combo_scale_enable3;
			break;
		case 3:
			m_pHwch[i] = &m_combo_hwch4;
			m_pRange[i] = &m_combo_range4;
			m_pChname[i] = &m_edit_ch_name4;
			m_pMindata[i] = &m_edit_min_data4;
			m_pMaxdata[i] = &m_edit_max_data4;
			m_pMinscale[i] = &m_edit_min_scale4;
			m_pMaxscale[i] = &m_edit_max_scale4;
			m_pScale_enable[i] = &m_combo_scale_enable4;
			break;
		default:
			m_pHwch[i] = &m_combo_hwch1;
			m_pRange[i] = &m_combo_range1;
			m_pChname[i] = &m_edit_ch_name1;
			m_pMindata[i] = &m_edit_min_data1;
			m_pMaxdata[i] = &m_edit_max_data1;
			m_pMinscale[i] = &m_edit_min_scale1;
			m_pMaxscale[i] = &m_edit_max_scale1;
			m_pScale_enable[i] = &m_combo_scale_enable1;
			break;
		}
		//----------------------------------------
		// Create the combobox for HWCh
		//----------------------------------------
		m_pHwch[i]->AddString(_T("0"));
		m_pHwch[i]->AddString(_T("1"));
		m_pHwch[i]->AddString(_T("2"));
		m_pHwch[i]->AddString(_T("3"));
		//----------------------------------------
		// Update the selection of HWCh combobox
		//----------------------------------------
		m_pHwch[i]->SetCurSel(m_channel_setting->ChannelNo[i]);
		//----------------------------------------
		// Update channel name display
		//----------------------------------------
		if(strlen(m_channel_setting->ChName[i]) > 0){
			MultiByteToWideChar(CP_ACP, 0, m_channel_setting->ChName[i], -1, temp, 256);
			m_pChname[i]->SetWindowTextW(temp);
		}
		else{
			m_pChname[i]->SetWindowTextW(_T(""));
		}
		//----------------------------------------
		// Create the combobox for analog input range
		//----------------------------------------
		m_pRange[i]->AddString(_T("-10 - +10V"));
		m_pRange[i]->AddString(_T("-5 - +5V"));
		m_pRange[i]->AddString(_T("-2.5 - +2.5V"));
		m_pRange[i]->AddString(_T("-1.25 - +1.25V"));
		m_pRange[i]->AddString(_T("0 - +10V"));
		m_pRange[i]->AddString(_T("0 - +5V"));
		m_pRange[i]->AddString(_T("0 - +2.5V"));
		m_pRange[i]->AddString(_T("0 - +1.25V"));
		m_pRange[i]->AddString(_T("0 - +20mA"));
		m_pRange[i]->AddString(_T("4 - +20mA"));
		m_pRange[i]->AddString(_T("-20 - +20mA"));
		m_pRange[i]->AddString(_T("1 - +5V"));
		//----------------------------------------
		// Update the selection of analog input range combobox
		//----------------------------------------
		ai_range_index = 0;
		for(j = 0; j < sizeof(g_ai_range); j++){
			if(m_channel_setting->Range[i] == g_ai_range[j]){
				ai_range_index = j;
				break;
			}
		}
		m_pRange[i]->SetCurSel(ai_range_index);
		//----------------------------------------
		// Create the combobox for scale enable/disable
		//----------------------------------------
		m_pScale_enable[i]->AddString(_T("Disable"));
		m_pScale_enable[i]->AddString(_T("Enable"));
		//----------------------------------------
		// Update the selection of scale enable/disable combobox
		//----------------------------------------
		m_pScale_enable[i]->SetCurSel(m_channel_setting->ScaleEnable[i]);
		//----------------------------------------
		// Update data 1 display
		//----------------------------------------
		text_temp.Format(_T("%f"), m_channel_setting->MinData[i]);
		m_pMindata[i]->SetWindowTextW(text_temp);
		//----------------------------------------
		// Update data 2 display
		//----------------------------------------
		text_temp.Format(_T("%f"), m_channel_setting->MaxData[i]);
		m_pMaxdata[i]->SetWindowTextW(text_temp);
		//----------------------------------------
		// Update minimum scale display
		//----------------------------------------
		text_temp.Format(_T("%f"), m_channel_setting->MinScale[i]);
		m_pMinscale[i]->SetWindowTextW(text_temp);
		//----------------------------------------
		// Update maximum scale display
		//----------------------------------------
		text_temp.Format(_T("%f"), m_channel_setting->MaxScale[i]);
		m_pMaxscale[i]->SetWindowTextW(text_temp);
	}
	//----------------------------------------
	// Call the input method combobox change event to update the display
	//----------------------------------------
	OnCbnSelchangeComboAichannels();
	return TRUE;  // return TRUE unless you set the focus to a control
}

//================================================================================
// It is the process when the Apply button is clicked
// Confirm the settings
//================================================================================
void ChannelSettigDlg::OnBnClickedOk()
{
	CHANNEL_SETTING		pre_channel_setting;		// For temporary storage of settings
	TCHAR				text_temp[256];				// For temporary text storage
	int					i;							// Loop count
	int					ai_range_index;				// Analog input range index

	//----------------------------------------
	// Get input method from combobox
	//----------------------------------------
	pre_channel_setting.InputType = m_combo_inputtype.GetCurSel();
	//----------------------------------------
	// Get the number of channels from the combobox (index + 1)
	//----------------------------------------
	pre_channel_setting.AiChannels = m_combo_ai_channels.GetCurSel() + 1;
	for(i = 0; i < SEQUENCE_NUM; i++){
		//----------------------------------------
		// Get HWch from combobox
		//----------------------------------------
		pre_channel_setting.ChannelNo[i] = m_pHwch[i]->GetCurSel();
		//----------------------------------------
		// Get the range from combobox
		//----------------------------------------
		ai_range_index = m_pRange[i]->GetCurSel();
		pre_channel_setting.Range[i] = g_ai_range[ai_range_index];
		//----------------------------------------
		// Get channel name from textbox
		//----------------------------------------
		m_pChname[i]->GetWindowText(text_temp, _countof(text_temp));
		WideCharToMultiByte(CP_ACP, 0, text_temp, -1, pre_channel_setting.ChName[i], 256, NULL, NULL);
		//----------------------------------------
		// Get scale enabled/disabled from combobox
		//----------------------------------------
		pre_channel_setting.ScaleEnable[i] = m_pScale_enable[i]->GetCurSel();
		//----------------------------------------
		// Get data 1 from textbox
		//----------------------------------------
		m_pMindata[i]->GetWindowText(text_temp, _countof(text_temp));
		pre_channel_setting.MinData[i] = (float)_ttof(text_temp);
		//----------------------------------------
		// Get data 2 from textbox
		//----------------------------------------
		m_pMaxdata[i]->GetWindowText(text_temp, _countof(text_temp));
		pre_channel_setting.MaxData[i] = (float)_ttof(text_temp);
		//----------------------------------------
		// Get minimum scale from textbox
		//----------------------------------------
		m_pMinscale[i]->GetWindowText(text_temp, _countof(text_temp));
		pre_channel_setting.MinScale[i] = (float)_ttof(text_temp);
		//----------------------------------------
		// Get maximum scale from textbox
		//----------------------------------------
		m_pMaxscale[i]->GetWindowText(text_temp, _countof(text_temp));
		pre_channel_setting.MaxScale[i] = (float)_ttof(text_temp);
	}

	//----------------------------------------
	// Copy from temporary storage to member variable
	//----------------------------------------
	memcpy(m_channel_setting, &pre_channel_setting, sizeof(CHANNEL_SETTING));

	CDialogEx::OnOK();
	return;
}

//================================================================================
// It is the process when the value of number of channels combobox is changed
// Check the setting value and enable/disable setting operations that are less than the number of channels
//================================================================================
void ChannelSettigDlg::OnCbnSelchangeComboAichannels()
{
	int				scale_enable;			// For scale conversion storage
	int				i;						// Loop count
	BOOL			sequence[SEQUENCE_NUM];	// Sequence enable/disable
	unsigned short	ai_channels;			// Number of channels

	//----------------------------------------
	// Get the number of channels from the combobox (index + 1)
	//----------------------------------------
	ai_channels = m_combo_ai_channels.GetCurSel() + 1;
	//----------------------------------------
	// Loop with the number of sequences
	//----------------------------------------
	for(i = 0; i < SEQUENCE_NUM; i++){
		//----------------------------------------
		// Disable settings that are less than the number of channels
		//----------------------------------------
		if(i < ai_channels){
			sequence[i] = TRUE;
		}else{
			sequence[i] = FALSE;
		}
		m_pHwch[i]->EnableWindow(sequence[i]);
		m_pRange[i]->EnableWindow(sequence[i]);
		m_pChname[i]->EnableWindow(sequence[i]);
		m_pScale_enable[i]->EnableWindow(sequence[i]);
		//----------------------------------------
		// Disable the scale setting operation
		//----------------------------------------
		if(sequence[i] == TRUE){
			scale_enable = m_pScale_enable[i]->GetCurSel();
			if(scale_enable == LOGGER_PARAM_DISABLE){
				m_pMindata[i]->EnableWindow(FALSE);
				m_pMaxdata[i]->EnableWindow(FALSE);
				m_pMinscale[i]->EnableWindow(FALSE);
				m_pMaxscale[i]->EnableWindow(FALSE);
			}else if(scale_enable == LOGGER_PARAM_ENABLE){
				m_pMindata[i]->EnableWindow(TRUE);
				m_pMaxdata[i]->EnableWindow(TRUE);
				m_pMinscale[i]->EnableWindow(TRUE);
				m_pMaxscale[i]->EnableWindow(TRUE);
			}else{
				m_pMindata[i]->EnableWindow(TRUE);
				m_pMaxdata[i]->EnableWindow(TRUE);
				m_pMinscale[i]->EnableWindow(TRUE);
				m_pMaxscale[i]->EnableWindow(TRUE);
			}
		}else{
			m_pMindata[i]->EnableWindow(sequence[i]);
			m_pMaxdata[i]->EnableWindow(sequence[i]);
			m_pMinscale[i]->EnableWindow(sequence[i]);
			m_pMaxscale[i]->EnableWindow(sequence[i]);
		}
	}
	return;
}

//================================================================================
// It is the process when the value of input method combobox is changed
// Check the setting value and change the setting range for the number of channels
//================================================================================
void ChannelSettigDlg::OnCbnSelchangeComboInputtype()
{
	int input_type;		// For input methods storage
	//----------------------------------------
	// Get input method from combobox
	//----------------------------------------
	input_type = m_combo_inputtype.GetCurSel();
	//----------------------------------------
	// Reset the number of channels combobox
	//----------------------------------------
	m_combo_ai_channels.ResetContent();
	//----------------------------------------
	// Creating the number of channels combobox
	//----------------------------------------
	m_combo_ai_channels.AddString(_T("1"));
	m_combo_ai_channels.AddString(_T("2"));
	//----------------------------------------
	// For single-end input
	//----------------------------------------
	if(input_type == LOGGER_PARAM_SINGLEENDED){
		m_combo_ai_channels.AddString(_T("3"));
		m_combo_ai_channels.AddString(_T("4"));
	}
	//----------------------------------------
	// Select the number of channels combobox
	//----------------------------------------
	m_combo_ai_channels.SetCurSel(0);
	//----------------------------------------
	// Call the number of channels combobox change event to update the display
	//----------------------------------------
	OnCbnSelchangeComboAichannels();
	return;
}

//================================================================================
// It is the process when the value of scale conversion combobox is changed
// Check the setting value and enable/disable the scale settings
//================================================================================
void ChannelSettigDlg::OnCbnSelchangeComboScaleenable1()
{
	int scale_enable;		// For scale conversion storage
	//----------------------------------------
	// Get the scale conversion
	//----------------------------------------
	scale_enable = m_combo_scale_enable1.GetCurSel();
	if(scale_enable == LOGGER_PARAM_DISABLE){
		//----------------------------------------
		// Disable
		//----------------------------------------
		m_edit_min_data1.EnableWindow(FALSE);
		m_edit_max_data1.EnableWindow(FALSE);
		m_edit_min_scale1.EnableWindow(FALSE);
		m_edit_max_scale1.EnableWindow(FALSE);
	}else if(scale_enable == LOGGER_PARAM_ENABLE){
		//----------------------------------------
		// Enable
		//----------------------------------------
		m_edit_min_data1.EnableWindow(TRUE);
		m_edit_max_data1.EnableWindow(TRUE);
		m_edit_min_scale1.EnableWindow(TRUE);
		m_edit_max_scale1.EnableWindow(TRUE);
	}else{
		//----------------------------------------
		// Enable
		//----------------------------------------
		m_edit_min_data1.EnableWindow(TRUE);
		m_edit_max_data1.EnableWindow(TRUE);
		m_edit_min_scale1.EnableWindow(TRUE);
		m_edit_max_scale1.EnableWindow(TRUE);
	}
}

//================================================================================
// It is the process when the value of scale conversion combobox is changed
// Check the setting value and enable/disable the scale settings
//================================================================================
void ChannelSettigDlg::OnCbnSelchangeComboScaleenable2()
{
	int scale_enable;		// For scale conversion storage
	//----------------------------------------
	// Get the scale conversion
	//----------------------------------------
	scale_enable = m_combo_scale_enable2.GetCurSel();
	if(scale_enable == LOGGER_PARAM_DISABLE){
		//----------------------------------------
		// Disable
		//----------------------------------------
		m_edit_min_data2.EnableWindow(FALSE);
		m_edit_max_data2.EnableWindow(FALSE);
		m_edit_min_scale2.EnableWindow(FALSE);
		m_edit_max_scale2.EnableWindow(FALSE);
	}else if(scale_enable == LOGGER_PARAM_ENABLE){
		//----------------------------------------
		// Enable
		//----------------------------------------
		m_edit_min_data2.EnableWindow(TRUE);
		m_edit_max_data2.EnableWindow(TRUE);
		m_edit_min_scale2.EnableWindow(TRUE);
		m_edit_max_scale2.EnableWindow(TRUE);
	}else{
		//----------------------------------------
		// Enable
		//----------------------------------------
		m_edit_min_data2.EnableWindow(TRUE);
		m_edit_max_data2.EnableWindow(TRUE);
		m_edit_min_scale2.EnableWindow(TRUE);
		m_edit_max_scale2.EnableWindow(TRUE);
	}
}

//================================================================================
// It is the process when the value of scale conversion combobox is changed
// Check the setting value and enable/disable the scale settings
//================================================================================
void ChannelSettigDlg::OnCbnSelchangeComboScaleenable3()
{
	int scale_enable;		// For scale conversion storage
	//----------------------------------------
	// Get the scale conversion
	//----------------------------------------
	scale_enable = m_combo_scale_enable3.GetCurSel();
	if(scale_enable == LOGGER_PARAM_DISABLE){
		//----------------------------------------
		// Disable
		//----------------------------------------
		m_edit_min_data3.EnableWindow(FALSE);
		m_edit_max_data3.EnableWindow(FALSE);
		m_edit_min_scale3.EnableWindow(FALSE);
		m_edit_max_scale3.EnableWindow(FALSE);
	}else if(scale_enable == LOGGER_PARAM_ENABLE){
		//----------------------------------------
		// Enable
		//----------------------------------------
		m_edit_min_data3.EnableWindow(TRUE);
		m_edit_max_data3.EnableWindow(TRUE);
		m_edit_min_scale3.EnableWindow(TRUE);
		m_edit_max_scale3.EnableWindow(TRUE);
	}else{
		//----------------------------------------
		// Enable
		//----------------------------------------
		m_edit_min_data3.EnableWindow(TRUE);
		m_edit_max_data3.EnableWindow(TRUE);
		m_edit_min_scale3.EnableWindow(TRUE);
		m_edit_max_scale3.EnableWindow(TRUE);
	}
}

//================================================================================
// It is the process when the value of scale conversion combobox is changed
// Check the setting value and enable/disable the scale settings
//================================================================================
void ChannelSettigDlg::OnCbnSelchangeComboScaleenable4()
{
	int scale_enable;		// For scale conversion storage
	//----------------------------------------
	// Get the scale conversion
	//----------------------------------------
	scale_enable = m_combo_scale_enable4.GetCurSel();
	if(scale_enable == LOGGER_PARAM_DISABLE){
		//----------------------------------------
		// Disable
		//----------------------------------------
		m_edit_min_data4.EnableWindow(FALSE);
		m_edit_max_data4.EnableWindow(FALSE);
		m_edit_min_scale4.EnableWindow(FALSE);
		m_edit_max_scale4.EnableWindow(FALSE);
	}else if(scale_enable == LOGGER_PARAM_ENABLE){
		//----------------------------------------
		// Enable
		//----------------------------------------
		m_edit_min_data4.EnableWindow(TRUE);
		m_edit_max_data4.EnableWindow(TRUE);
		m_edit_min_scale4.EnableWindow(TRUE);
		m_edit_max_scale4.EnableWindow(TRUE);
	}else{
		//----------------------------------------
		// Enable
		//----------------------------------------
		m_edit_min_data4.EnableWindow(TRUE);
		m_edit_max_data4.EnableWindow(TRUE);
		m_edit_min_scale4.EnableWindow(TRUE);
		m_edit_max_scale4.EnableWindow(TRUE);
	}
}
