// Trigger.cpp : implementation file
//

#include "stdafx.h"
#include "CheckTr.h"
#include "Trigger.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTrigger dialog


CTrigger::CTrigger(CWnd* pParent /*=NULL*/)
	: CDialog(CTrigger::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTrigger)
	m_noTrig = FALSE;
	m_OptTrig = FALSE;
	m_ExtTrig = FALSE;
	m_BothEdgesElectr = FALSE;
	m_OneTimeElectr = FALSE;
	m_FallEdgeElectr = FALSE;
	m_FallEdgeOneTineOpt = FALSE;
	m_FallEdgeOpt = FALSE;
	m_RisingEdgeElectr = FALSE;
	m_RisingEdgeOneTimeOpt = FALSE;
	m_RisingEdgeOpt = FALSE;
	m_ThreshOpt = FALSE;
	m_TrigIntensity = _T("");
	m_TrigWavelength = _T("");
	//}}AFX_DATA_INIT
}


void CTrigger::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTrigger)
	DDX_Check(pDX, IDC_NOTRIG, m_noTrig);
	DDX_Check(pDX, IDC_OPTTRIGG, m_OptTrig);
	DDX_Check(pDX, IDC_EXTTRIG, m_ExtTrig);
	DDX_Check(pDX, IDC_ONBOTHEDGESELECTR, m_BothEdgesElectr);
	DDX_Check(pDX, IDC_ONETIMETRIGELECTR, m_OneTimeElectr);
	DDX_Check(pDX, IDC_ONFALLEDGEELECTR, m_FallEdgeElectr);
	DDX_Check(pDX, IDC_ONFALLEDGEONETIMEOPT, m_FallEdgeOneTineOpt);
	DDX_Check(pDX, IDC_ONFALLEDGEOPT, m_FallEdgeOpt);
	DDX_Check(pDX, IDC_ONRISINGEDGEELECTR, m_RisingEdgeElectr);
	DDX_Check(pDX, IDC_ONRISINGEDGEONETIMEOPT, m_RisingEdgeOneTimeOpt);
	DDX_Check(pDX, IDC_ONRISINGEDGEOPT, m_RisingEdgeOpt);
	DDX_Check(pDX, IDC_ONTHRHOPT, m_ThreshOpt);
	DDX_Text(pDX, IDC_TRIGINT, m_TrigIntensity);
	DDX_Text(pDX, IDC_TRIGWLNGH, m_TrigWavelength);
	//}}AFX_DATA_MAP
	if(TrigStat==0)
	{
		CButton* NoTrig = (CButton*) GetDlgItem(IDC_NOTRIG);
		NoTrig->SetCheck(1);
		CButton* ExtTrig = (CButton*) GetDlgItem(IDC_EXTTRIG);
		ExtTrig->SetCheck(0);
		CButton* OptTrig = (CButton*) GetDlgItem(IDC_OPTTRIGG);
		OptTrig->SetCheck(0);
		CButton* BothEdgeElectr = (CButton*) GetDlgItem(IDC_ONBOTHEDGESELECTR);
		BothEdgeElectr->EnableWindow(0);
		CButton* FallEdgeElectr = (CButton*) GetDlgItem(IDC_ONFALLEDGEELECTR);
		FallEdgeElectr->EnableWindow(0);
		CButton* RisingEdgeElectr = (CButton*) GetDlgItem(IDC_ONRISINGEDGEELECTR);
		RisingEdgeElectr->EnableWindow(0);
		CButton* OneTimeElectr = (CButton*) GetDlgItem(IDC_ONETIMETRIGELECTR);
		OneTimeElectr->EnableWindow(0);
		CButton* FallEdgeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEOPT);
		FallEdgeOpt->EnableWindow(0);
		CButton* RisingEdgeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEOPT);
		RisingEdgeOpt->EnableWindow(0);
		CButton* ThresholdOpt = (CButton*) GetDlgItem(IDC_ONTHRHOPT);
		ThresholdOpt->EnableWindow(0);
		CButton* RisingEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEONETIMEOPT);
		RisingEdgeOneTimeOpt->EnableWindow(0);
		CButton* FallEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEONETIMEOPT);
		FallEdgeOneTimeOpt->EnableWindow(0);
	}
	if(TrigStat==1)
	{
		CButton* NoTrig = (CButton*) GetDlgItem(IDC_NOTRIG);
		NoTrig->SetCheck(0);
		CButton* ExtTrig = (CButton*) GetDlgItem(IDC_EXTTRIG);
		ExtTrig->SetCheck(1);
		CButton* OptTrig = (CButton*) GetDlgItem(IDC_OPTTRIGG);
		OptTrig->SetCheck(0);

		CButton* BothEdgeElectr = (CButton*) GetDlgItem(IDC_ONBOTHEDGESELECTR);
		BothEdgeElectr->EnableWindow(1);
		CButton* FallEdgeElectr = (CButton*) GetDlgItem(IDC_ONFALLEDGEELECTR);
		FallEdgeElectr->EnableWindow(1);
		CButton* RisingEdgeElectr = (CButton*) GetDlgItem(IDC_ONRISINGEDGEELECTR);
		RisingEdgeElectr->EnableWindow(1);
		CButton* OneTimeElectr = (CButton*) GetDlgItem(IDC_ONETIMETRIGELECTR);
		OneTimeElectr->EnableWindow(1);
		CButton* FallEdgeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEOPT);
		FallEdgeOpt->EnableWindow(0);
		CButton* RisingEdgeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEOPT);
		RisingEdgeOpt->EnableWindow(0);
		CButton* ThresholdOpt = (CButton*) GetDlgItem(IDC_ONTHRHOPT);
		ThresholdOpt->EnableWindow(0);
		CButton* RisingEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEONETIMEOPT);
		RisingEdgeOneTimeOpt->EnableWindow(0);
		CButton* FallEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEONETIMEOPT);
		FallEdgeOneTimeOpt->EnableWindow(0);
	}
	if(TrigStat==1)
	{
		CButton* NoTrig = (CButton*) GetDlgItem(IDC_NOTRIG);
		NoTrig->SetCheck(0);
		CButton* ExtTrig = (CButton*) GetDlgItem(IDC_EXTTRIG);
		ExtTrig->SetCheck(0);
		CButton* OptTrig = (CButton*) GetDlgItem(IDC_OPTTRIGG);
		OptTrig->SetCheck(1);

		CButton* BothEdgeElectr = (CButton*) GetDlgItem(IDC_ONBOTHEDGESELECTR);
		BothEdgeElectr->EnableWindow(0);
		CButton* FallEdgeElectr = (CButton*) GetDlgItem(IDC_ONFALLEDGEELECTR);
		FallEdgeElectr->EnableWindow(0);
		CButton* RisingEdgeElectr = (CButton*) GetDlgItem(IDC_ONRISINGEDGEELECTR);
		RisingEdgeElectr->EnableWindow(0);
		CButton* OneTimeElectr = (CButton*) GetDlgItem(IDC_ONETIMETRIGELECTR);
		OneTimeElectr->EnableWindow(0);
		CButton* FallEdgeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEOPT);
		FallEdgeOpt->EnableWindow(1);
		CButton* RisingEdgeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEOPT);
		RisingEdgeOpt->EnableWindow(1);
		CButton* ThresholdOpt = (CButton*) GetDlgItem(IDC_ONTHRHOPT);
		ThresholdOpt->EnableWindow(1);
		CButton* RisingEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEONETIMEOPT);
		RisingEdgeOneTimeOpt->EnableWindow(1);
		CButton* FallEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEONETIMEOPT);
		FallEdgeOneTimeOpt->EnableWindow(1);
	}
}


BEGIN_MESSAGE_MAP(CTrigger, CDialog)
	//{{AFX_MSG_MAP(CTrigger)
	ON_BN_CLICKED(IDC_NOTRIG, OnNotrig)
	ON_BN_CLICKED(IDC_EXTTRIG, OnExttrig)
	ON_BN_CLICKED(IDC_OPTTRIGG, OnOpttrigg)
	ON_BN_CLICKED(IDC_ONBOTHEDGESELECTR, OnOnbothedgeselectr)
	ON_BN_CLICKED(IDC_ONFALLEDGEELECTR, OnOnfalledgeelectr)
	ON_BN_CLICKED(IDC_ONFALLEDGEONETIMEOPT, OnOnfalledgeonetimeopt)
	ON_BN_CLICKED(IDC_ONFALLEDGEOPT, OnOnfalledgeopt)
	ON_BN_CLICKED(IDC_ONRISINGEDGEELECTR, OnOnrisingedgeelectr)
	ON_BN_CLICKED(IDC_ONRISINGEDGEONETIMEOPT, OnOnrisingedgeonetimeopt)
	ON_BN_CLICKED(IDC_ONRISINGEDGEOPT, OnOnrisingedgeopt)
	ON_BN_CLICKED(IDC_ONTHRHOPT, OnOnthrhopt)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTrigger message handlers

void CTrigger::OnNotrig() 
{
		TrigStat=0;
		CButton* NoTrig = (CButton*) GetDlgItem(IDC_NOTRIG);
		NoTrig->SetCheck(1);
		CButton* ExtTrig = (CButton*) GetDlgItem(IDC_EXTTRIG);
		ExtTrig->SetCheck(0);
		CButton* OptTrig = (CButton*) GetDlgItem(IDC_OPTTRIGG);
		OptTrig->SetCheck(0);

		CButton* BothEdgeElectr = (CButton*) GetDlgItem(IDC_ONBOTHEDGESELECTR);
		BothEdgeElectr->EnableWindow(0);
		CButton* FallEdgeElectr = (CButton*) GetDlgItem(IDC_ONFALLEDGEELECTR);
		FallEdgeElectr->EnableWindow(0);
		CButton* RisingEdgeElectr = (CButton*) GetDlgItem(IDC_ONRISINGEDGEELECTR);
		RisingEdgeElectr->EnableWindow(0);
		CButton* OneTimeElectr = (CButton*) GetDlgItem(IDC_ONETIMETRIGELECTR);
		OneTimeElectr->EnableWindow(0);
		CButton* FallEdgeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEOPT);
		FallEdgeOpt->EnableWindow(0);
		CButton* RisingEdgeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEOPT);
		RisingEdgeOpt->EnableWindow(0);
		CButton* ThresholdOpt = (CButton*) GetDlgItem(IDC_ONTHRHOPT);
		ThresholdOpt->EnableWindow(0);
		CButton* RisingEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEONETIMEOPT);
		RisingEdgeOneTimeOpt->EnableWindow(0);
		CButton* FallEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEONETIMEOPT);
		FallEdgeOneTimeOpt->EnableWindow(0);
}

void CTrigger::OnExttrig() 
{
	TrigStat=1;
	CButton* NoTrig = (CButton*) GetDlgItem(IDC_NOTRIG);
	NoTrig->SetCheck(0);
	CButton* ExtTrig = (CButton*) GetDlgItem(IDC_EXTTRIG);
	ExtTrig->SetCheck(1);
	CButton* OptTrig = (CButton*) GetDlgItem(IDC_OPTTRIGG);
	OptTrig->SetCheck(0);

	CButton* BothEdgeElectr = (CButton*) GetDlgItem(IDC_ONBOTHEDGESELECTR);
	BothEdgeElectr->EnableWindow(1);
	CButton* FallEdgeElectr = (CButton*) GetDlgItem(IDC_ONFALLEDGEELECTR);
	FallEdgeElectr->EnableWindow(1);
	CButton* RisingEdgeElectr = (CButton*) GetDlgItem(IDC_ONRISINGEDGEELECTR);
	RisingEdgeElectr->EnableWindow(1);
	CButton* OneTimeElectr = (CButton*) GetDlgItem(IDC_ONETIMETRIGELECTR);
	OneTimeElectr->EnableWindow(1);
	CButton* FallEdgeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEOPT);
	FallEdgeOpt->EnableWindow(0);
	CButton* RisingEdgeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEOPT);
	RisingEdgeOpt->EnableWindow(0);
	CButton* ThresholdOpt = (CButton*) GetDlgItem(IDC_ONTHRHOPT);
	ThresholdOpt->EnableWindow(0);
	CButton* RisingEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEONETIMEOPT);
	RisingEdgeOneTimeOpt->EnableWindow(0);
	CButton* FallEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEONETIMEOPT);
	FallEdgeOneTimeOpt->EnableWindow(0);
}

void CTrigger::OnOpttrigg() 
{
	TrigStat=2;
		
	CButton* NoTrig = (CButton*) GetDlgItem(IDC_NOTRIG);
	NoTrig->SetCheck(0);
	CButton* ExtTrig = (CButton*) GetDlgItem(IDC_EXTTRIG);
	ExtTrig->SetCheck(0);
	CButton* OptTrig = (CButton*) GetDlgItem(IDC_OPTTRIGG);
	OptTrig->SetCheck(1);
	CButton* BothEdgeElectr = (CButton*) GetDlgItem(IDC_ONBOTHEDGESELECTR);
	BothEdgeElectr->EnableWindow(0);
	CButton* FallEdgeElectr = (CButton*) GetDlgItem(IDC_ONFALLEDGEELECTR);
	FallEdgeElectr->EnableWindow(0);
	CButton* RisingEdgeElectr = (CButton*) GetDlgItem(IDC_ONRISINGEDGEELECTR);
	RisingEdgeElectr->EnableWindow(0);
	CButton* OneTimeElectr = (CButton*) GetDlgItem(IDC_ONETIMETRIGELECTR);
	OneTimeElectr->EnableWindow(0);
	CButton* FallEdgeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEOPT);
	FallEdgeOpt->EnableWindow(1);
	CButton* RisingEdgeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEOPT);
	RisingEdgeOpt->EnableWindow(1);
	CButton* ThresholdOpt = (CButton*) GetDlgItem(IDC_ONTHRHOPT);
	ThresholdOpt->EnableWindow(1);
	CButton* RisingEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEONETIMEOPT);
	RisingEdgeOneTimeOpt->EnableWindow(1);
	CButton* FallEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEONETIMEOPT);
	FallEdgeOneTimeOpt->EnableWindow(1);
}

void CTrigger::OnOnbothedgeselectr() 
{	
	CButton* BothEdgeElectr = (CButton*) GetDlgItem(IDC_ONBOTHEDGESELECTR);
	BothEdgeElectr->SetCheck(1);
	CButton* FallEdgeElectr = (CButton*) GetDlgItem(IDC_ONFALLEDGEELECTR);
	FallEdgeElectr->SetCheck(0);
	CButton* RisingEdgeElectr = (CButton*) GetDlgItem(IDC_ONRISINGEDGEELECTR);
	RisingEdgeElectr->SetCheck(0);
}

void CTrigger::OnOnfalledgeelectr() 
{	
	CButton* BothEdgeElectr = (CButton*) GetDlgItem(IDC_ONBOTHEDGESELECTR);
	BothEdgeElectr->SetCheck(0);
	CButton* FallEdgeElectr = (CButton*) GetDlgItem(IDC_ONFALLEDGEELECTR);
	FallEdgeElectr->SetCheck(1);
	CButton* RisingEdgeElectr = (CButton*) GetDlgItem(IDC_ONRISINGEDGEELECTR);
	RisingEdgeElectr->SetCheck(0);
}

void CTrigger::OnOnfalledgeonetimeopt() 
{	
	CButton* FallEdgeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEOPT);
	FallEdgeOpt->SetCheck(0);
	CButton* RisingEdgeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEOPT);
	RisingEdgeOpt->SetCheck(0);
	CButton* ThresholdOpt = (CButton*) GetDlgItem(IDC_ONTHRHOPT);
	ThresholdOpt->SetCheck(0);
	CButton* RisingEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEONETIMEOPT);
	RisingEdgeOneTimeOpt->SetCheck(0);
	CButton* FallEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEONETIMEOPT);
	FallEdgeOneTimeOpt->SetCheck(1);
}

void CTrigger::OnOnfalledgeopt() 
{	
	CButton* FallEdgeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEOPT);
	FallEdgeOpt->SetCheck(1);
	CButton* RisingEdgeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEOPT);
	RisingEdgeOpt->SetCheck(0);
	CButton* ThresholdOpt = (CButton*) GetDlgItem(IDC_ONTHRHOPT);
	ThresholdOpt->SetCheck(0);
	CButton* RisingEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEONETIMEOPT);
	RisingEdgeOneTimeOpt->SetCheck(0);
	CButton* FallEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEONETIMEOPT);
	FallEdgeOneTimeOpt->SetCheck(0);
}

void CTrigger::OnOnrisingedgeelectr() 
{	
	CButton* BothEdgeElectr = (CButton*) GetDlgItem(IDC_ONBOTHEDGESELECTR);
	BothEdgeElectr->SetCheck(0);
	CButton* FallEdgeElectr = (CButton*) GetDlgItem(IDC_ONFALLEDGEELECTR);
	FallEdgeElectr->SetCheck(0);
	CButton* RisingEdgeElectr = (CButton*) GetDlgItem(IDC_ONRISINGEDGEELECTR);
	RisingEdgeElectr->SetCheck(1);
}

void CTrigger::OnOnrisingedgeonetimeopt() 
{	
	CButton* FallEdgeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEOPT);
	FallEdgeOpt->SetCheck(0);
	CButton* RisingEdgeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEOPT);
	RisingEdgeOpt->SetCheck(0);
	CButton* ThresholdOpt = (CButton*) GetDlgItem(IDC_ONTHRHOPT);
	ThresholdOpt->SetCheck(0);
	CButton* RisingEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEONETIMEOPT);
	RisingEdgeOneTimeOpt->SetCheck(1);
	CButton* FallEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEONETIMEOPT);
	FallEdgeOneTimeOpt->SetCheck(0);
}

void CTrigger::OnOnrisingedgeopt() 
{	
	CButton* FallEdgeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEOPT);
	FallEdgeOpt->SetCheck(0);
	CButton* RisingEdgeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEOPT);
	RisingEdgeOpt->SetCheck(1);
	CButton* ThresholdOpt = (CButton*) GetDlgItem(IDC_ONTHRHOPT);
	ThresholdOpt->SetCheck(0);
	CButton* RisingEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEONETIMEOPT);
	RisingEdgeOneTimeOpt->SetCheck(0);
	CButton* FallEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEONETIMEOPT);
	FallEdgeOneTimeOpt->SetCheck(0);
}

void CTrigger::OnOnthrhopt() 
{	
	CButton* FallEdgeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEOPT);
	FallEdgeOpt->SetCheck(0);
	CButton* RisingEdgeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEOPT);
	RisingEdgeOpt->SetCheck(0);
	CButton* ThresholdOpt = (CButton*) GetDlgItem(IDC_ONTHRHOPT);
	ThresholdOpt->SetCheck(1);
	CButton* RisingEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONRISINGEDGEONETIMEOPT);
	RisingEdgeOneTimeOpt->SetCheck(0);
	CButton* FallEdgeOneTimeOpt = (CButton*) GetDlgItem(IDC_ONFALLEDGEONETIMEOPT);
	FallEdgeOneTimeOpt->SetCheck(0);
}
