// DlgSystemLight.cpp : ±¸Çö ÆÄÀÏÀÔ´Ï´Ù.
|
//
|
|
#include "stdafx.h"
|
#include "ReviewSystemSetting.h"
|
#include "DlgSystemLight.h"
|
#include "ReviewSystemSettingDlg.h"
|
#include "CHReviewSetting/HeaderInfo.h"
|
#include "CHCommonControls/GridCellCombo.h"
|
#include "CHCommonControls/GridCellCheck.h"
|
#include "CHReviewSetting/SystemInfo.h"
|
|
// CDlgSystemLight ´ëÈ »óÀÚÀÔ´Ï´Ù.
|
|
IMPLEMENT_DYNAMIC(CDlgSystemLight, CDialog)
|
|
CDlgSystemLight::CDlgSystemLight(CWnd* pParent /*=NULL*/)
|
: CDialog(CDlgSystemLight::IDD, pParent)
|
, m_nGantryIdx(0)
|
, m_nHeaderIdx(0)
|
{
|
m_nLightCount = 0;
|
}
|
|
CDlgSystemLight::~CDlgSystemLight()
|
{
|
}
|
|
void CDlgSystemLight::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialog::DoDataExchange(pDX);
|
DDX_Control(pDX, IDC_GRID_SYSTEM_LIGHT_INFO, m_ctrlGridLightInfo);
|
DDX_Text(pDX, IDC_EDIT_SYS_SL_GANTRY_IDX, m_nGantryIdx);
|
DDX_Text(pDX, IDC_EDIT_SYS_SL_HEADER_IDX, m_nHeaderIdx);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CDlgSystemLight, CDialog)
|
ON_BN_CLICKED(IDC_BUTTON_SYS_SYSTEM_LIGHT_RESET, &CDlgSystemLight::OnBnClickedButtonSysSystemLightReset)
|
ON_BN_CLICKED(IDC_BUTTON_SYS_SYSTEM_LIGHT_APPLY, &CDlgSystemLight::OnBnClickedButtonSysSystemLightApply)
|
END_MESSAGE_MAP()
|
|
|
// CDlgSystemLight ¸Þ½ÃÁö 󸮱âÀÔ´Ï´Ù.
|
|
BOOL CDlgSystemLight::OnInitDialog()
|
{
|
CDialog::OnInitDialog();
|
|
// TODO: ¿©±â¿¡ Ãß°¡ ÃʱâÈ ÀÛ¾÷À» Ãß°¡ÇÕ´Ï´Ù.
|
InitLightInfoGridControl();
|
FillLightInfo();
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
// ¿¹¿Ü: OCX ¼Ó¼º ÆäÀÌÁö´Â FALSE¸¦ ¹ÝÈ¯ÇØ¾ß ÇÕ´Ï´Ù.
|
}
|
|
BOOL CDlgSystemLight::PreTranslateMessage(MSG* pMsg)
|
{
|
// TODO: ¿©±â¿¡ Ư¼öÈµÈ Äڵ带 Ãß°¡ ¹×/¶Ç´Â ±âº» Ŭ·¡½º¸¦ È£ÃâÇÕ´Ï´Ù.
|
if( pMsg->message == WM_KEYDOWN )
|
{
|
if(pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE )
|
{
|
::TranslateMessage(pMsg);
|
::DispatchMessage(pMsg);
|
return TRUE;
|
}
|
}
|
return CDialog::PreTranslateMessage(pMsg);
|
}
|
|
void CDlgSystemLight::OnBnClickedButtonSysSystemLightReset()
|
{
|
ResetLightInfoGrid();
|
}
|
|
void CDlgSystemLight::OnBnClickedButtonSysSystemLightApply()
|
{
|
UpdateData(TRUE);
|
|
CReviewSystemSettingDlg* pDlg = (CReviewSystemSettingDlg*)AfxGetMainWnd();
|
if (pDlg==NULL) return;
|
|
CHeaderInfo* pHeaderInfo = pDlg->GetSys_HeaderInfo(m_nGantryIdx, m_nHeaderIdx);
|
if (pHeaderInfo==NULL) return;
|
|
int nColIdx = 1;
|
CString strItemText = _T("");
|
CStringArray strArrayOption;
|
int nLightCount = pHeaderInfo->GetLightInfoCount();
|
|
for(int i=0; i<nLightCount; i++)
|
{
|
int nRowIdx = 1;
|
CLightControlInfo *pLightInfo = pHeaderInfo->GetLightInfo(i);
|
if (pLightInfo==NULL) continue;
|
|
pLightInfo->Reset();
|
|
//1. Total Index
|
strItemText = m_ctrlGridLightInfo.GetItemText(nRowIdx, nColIdx);
|
pLightInfo->SetIndex(_ttoi(strItemText));
|
|
// Name
|
nRowIdx++;
|
strItemText = m_ctrlGridLightInfo.GetItemText(nRowIdx, nColIdx);
|
pLightInfo->SetName(strItemText);
|
|
//1. Á¶¸í ¿¬°á ŸÀÔ
|
nRowIdx++;
|
CGridCellCombo *pCellCombo = (CGridCellCombo*)m_ctrlGridLightInfo.GetCell(nRowIdx, nColIdx);
|
if(pCellCombo)
|
{
|
strArrayOption.RemoveAll();
|
strItemText = pCellCombo->GetText();
|
pCellCombo->GetOptions(strArrayOption);
|
|
int nArrayCount = (int)strArrayOption.GetCount();
|
|
for(int j=0; j<nArrayCount; j++)
|
{
|
CString strTemp = strArrayOption.GetAt(j);
|
if(strTemp.Compare(strItemText) == 0)
|
{
|
pLightInfo->SetControllerType(j);
|
break;
|
}
|
}
|
}
|
|
//2. Æ÷Æ® ¹øÈ£
|
nRowIdx++;
|
strItemText = m_ctrlGridLightInfo.GetItemText(nRowIdx, nColIdx);
|
pLightInfo->SetConnectionPort(strItemText);
|
|
//3. BaudRate
|
nRowIdx++;
|
strItemText = m_ctrlGridLightInfo.GetItemText(nRowIdx, nColIdx);
|
pLightInfo->SetBaudRate(_ttoi(strItemText));
|
|
//4. ±âº» ±¤·®°ª
|
nRowIdx++;
|
strItemText = m_ctrlGridLightInfo.GetItemText(nRowIdx, nColIdx);
|
pLightInfo->SetDefaultValue(_ttoi(strItemText));
|
|
//5. ÃÖ´ë ±¤·®°ª
|
nRowIdx++;
|
strItemText = m_ctrlGridLightInfo.GetItemText(nRowIdx, nColIdx);
|
pLightInfo->SetMaxValue(_ttoi(strItemText));
|
|
//6. ÃÖ¼Ò ±¤·®°ª
|
nRowIdx++;
|
strItemText = m_ctrlGridLightInfo.GetItemText(nRowIdx, nColIdx);
|
pLightInfo->SetMinValue(_ttoi(strItemText));
|
|
nColIdx++;
|
}
|
}
|
|
void CDlgSystemLight::InitLightInfoGridControl()
|
{
|
int nRowIdx, nColIdx, nRows, nCols, nFixRows, nFixCols;
|
CString strTemp;
|
|
nRows = LIGHT_INFO_GRID_ROW_COUNT;
|
nCols = m_nLightCount + 1;
|
nFixRows = 1;
|
nFixCols = 1;
|
nRowIdx = 0;
|
nColIdx = 0;
|
|
m_ctrlGridLightInfo.GetDefaultCell(FALSE, FALSE)->SetBackClr(RGB(0xFF, 0xFF, 0xE0));
|
m_ctrlGridLightInfo.SetRowCount(nRows);
|
m_ctrlGridLightInfo.SetColumnCount(nCols);
|
m_ctrlGridLightInfo.SetFixedRowCount(nFixRows);
|
m_ctrlGridLightInfo.SetFixedColumnCount(nFixCols);
|
|
GV_ITEM Item;
|
|
Item.mask = GVIF_TEXT;
|
Item.row = nRowIdx++;
|
Item.col = nColIdx;
|
strTemp.Format(_T("Index")); //_T("À妽º"));
|
Item.strText = strTemp;
|
m_ctrlGridLightInfo.SetItem(&Item);
|
|
Item.row = nRowIdx++;
|
Item.col = nColIdx;
|
strTemp.Format(_T("Total Index")); //_T("ÅäÅ» ÀÎÅØ½º"));
|
Item.strText = strTemp;
|
m_ctrlGridLightInfo.SetItem(&Item);
|
|
Item.row = nRowIdx++;
|
Item.col = nColIdx;
|
strTemp.Format(_T("Name")); //_T("Á¶¸í À̸§"));
|
Item.strText = strTemp;
|
m_ctrlGridLightInfo.SetItem(&Item);
|
|
Item.row = nRowIdx++;
|
Item.col = nColIdx;
|
strTemp.Format(_T("Controller Type")); //_T("ÄÁÆ®·Ñ·¯ ŸÀÔ"));
|
Item.strText = strTemp;
|
m_ctrlGridLightInfo.SetItem(&Item);
|
|
Item.row = nRowIdx++;
|
Item.col = nColIdx;
|
strTemp.Format(_T("Connection Infomation"));//_T("¿¬°á Á¤º¸"));
|
Item.strText = strTemp;
|
m_ctrlGridLightInfo.SetItem(&Item);
|
|
Item.row = nRowIdx++;
|
Item.col = nColIdx;
|
strTemp.Format(_T("Baud Rate (bps)")); //_T("Åë½Å ¼Óµµ"));
|
Item.strText = strTemp;
|
m_ctrlGridLightInfo.SetItem(&Item);
|
|
Item.row = nRowIdx++;
|
Item.col = nColIdx;
|
strTemp.Format(_T("Default Level")); //_T("±âº» ±¤·® °ª"));
|
Item.strText = strTemp;
|
m_ctrlGridLightInfo.SetItem(&Item);
|
|
Item.row = nRowIdx++;
|
Item.col = nColIdx;
|
strTemp.Format(_T("Maximum Level")); //_T("ÃÖ´ë ±¤·® °ª"));
|
Item.strText = strTemp;
|
m_ctrlGridLightInfo.SetItem(&Item);
|
|
Item.row = nRowIdx++;
|
Item.col = nColIdx;
|
strTemp.Format(_T("Minimum Level")); //_T("ÃÖ¼Ò ±¤·® °ª"));
|
Item.strText = strTemp;
|
m_ctrlGridLightInfo.SetItem(&Item);
|
|
m_ctrlGridLightInfo.AutoSize();
|
}
|
|
void CDlgSystemLight::FillLightInfo()
|
{
|
ChangeLightCountLightInfoGridControl();
|
|
CReviewSystemSettingDlg* pDlg = (CReviewSystemSettingDlg*)AfxGetMainWnd();
|
if (pDlg==NULL) return;
|
|
CHeaderInfo *pHeaderInfo = pDlg->GetSys_HeaderInfo(m_nGantryIdx, m_nHeaderIdx);
|
if (pHeaderInfo==NULL) return;
|
|
int nLightCount = pHeaderInfo->GetLightInfoCount();
|
CStringArray strArrayOption;
|
CString strItemText = _T("");
|
int nColIdx = 1;
|
|
for(int i=0; i<nLightCount; i++)
|
{
|
int nRowIdx = 1;
|
CLightControlInfo *pLightInfo = pHeaderInfo->GetLightInfo(i);
|
if (pLightInfo==NULL) continue;
|
|
// 1. ÅäÅ» ÀÎÅØ½º
|
strItemText.Format(_T("%d"), pLightInfo->GetIndex());
|
m_ctrlGridLightInfo.SetItemText(nRowIdx, nColIdx, strItemText);
|
|
// 2. Á¶¸í À̸§
|
nRowIdx++;
|
strItemText.Format(_T("%s"), pLightInfo->GetName());
|
m_ctrlGridLightInfo.SetItemText(nRowIdx, nColIdx, strItemText);
|
|
// 3. ÄÁÆ®·Ñ·¯ ŸÀÔ
|
nRowIdx++;
|
CGridCellCombo *pCellCombo = (CGridCellCombo*)m_ctrlGridLightInfo.GetCell(nRowIdx, nColIdx);
|
|
if(pCellCombo)
|
{
|
strArrayOption.RemoveAll();
|
pCellCombo->GetOptions(strArrayOption);
|
if(strArrayOption.GetSize() > 0 && pLightInfo->GetControllerType() > -1)
|
{
|
strItemText = strArrayOption.GetAt(pLightInfo->GetControllerType());
|
m_ctrlGridLightInfo.SetItemText(nRowIdx, nColIdx, strItemText);
|
}
|
}
|
|
// 4. ¿¬°á Á¤º¸
|
nRowIdx++;
|
m_ctrlGridLightInfo.SetItemText(nRowIdx, nColIdx, pLightInfo->GetConnectionPort());
|
|
// 5. Åë½Å ¼Óµµ
|
nRowIdx++;
|
strItemText.Format(_T("%d"), pLightInfo->GetBaudRate());
|
m_ctrlGridLightInfo.SetItemText(nRowIdx, nColIdx, strItemText);
|
|
// 6. ±âº» ±¤·® °ª
|
nRowIdx++;
|
strItemText.Format(_T("%d"), pLightInfo->GetDefaultValue());
|
m_ctrlGridLightInfo.SetItemText(nRowIdx, nColIdx, strItemText);
|
|
// 7. ÃÖ´ë ±¤·® °ª
|
nRowIdx++;
|
strItemText.Format(_T("%d"), pLightInfo->GetMaxValue());
|
m_ctrlGridLightInfo.SetItemText(nRowIdx, nColIdx, strItemText);
|
|
// 8. ÃÖ¼Ò ±¤·® °ª
|
nRowIdx++;
|
strItemText.Format(_T("%d"), pLightInfo->GetMinValue());
|
m_ctrlGridLightInfo.SetItemText(nRowIdx, nColIdx, strItemText);
|
|
nColIdx++;
|
}
|
}
|
|
void CDlgSystemLight::ChangeLightCountLightInfoGridControl()
|
{
|
int i, j, nRowIdx, nColIdx;
|
int nWidth, nMargin, nDataColumnWidth;
|
CString strTemp;
|
CRect rect;
|
|
m_ctrlGridLightInfo.GetWindowRect(&rect);
|
m_ctrlGridLightInfo.SetColumnCount(m_nLightCount + 1);
|
nWidth = m_ctrlGridLightInfo.GetColumnWidth(0);
|
|
nMargin = 5;
|
nDataColumnWidth = rect.Width() - nWidth - nMargin;
|
|
if(m_nLightCount > 0)
|
{
|
GV_ITEM Item;
|
CStringArray strArrayOption;
|
CGridCellCombo* pCellCombo = NULL;
|
|
nColIdx = 1;
|
nDataColumnWidth = nDataColumnWidth / m_nLightCount;
|
|
for(i = 0; i < m_nLightCount; i++)
|
{
|
m_ctrlGridLightInfo.SetColumnWidth(i + 1, nDataColumnWidth);
|
|
//Á¶¸í À妽º
|
nRowIdx = 0;
|
Item.mask = GVIF_TEXT;
|
Item.row = nRowIdx;
|
Item.col = nColIdx;
|
strTemp.Format(_T("%02d"), i);
|
Item.strText = strTemp;
|
m_ctrlGridLightInfo.SetItem(&Item);
|
|
// 1. ÅäÅ» ÀÎÅØ½º
|
nRowIdx++;
|
// 2. Á¶¸í À̸§
|
nRowIdx++;
|
|
// 3. ÄÁÆ®·Ñ·¯ ŸÀÔ
|
nRowIdx++;
|
strArrayOption.RemoveAll();
|
|
for(j = 0; j < LightController_Count; j++)
|
{
|
switch(j)
|
{
|
case LightController_Simulation:
|
strTemp.Format(_T("Simulation"));
|
break;
|
case LightController_ShinHan:
|
strTemp.Format(_T("ShinHan LED"));
|
break;
|
case LightController_KSVision:
|
strTemp.Format(_T("KS Vision LED"));
|
break;
|
case LightController_PlusTek:
|
strTemp.Format(_T("PlusTek LED"));
|
break;
|
case LightController_Byon_ERI2:
|
strTemp.Format(_T("Byon LED"));
|
break;
|
case LightController_ALT_2RSD:
|
strTemp.Format(_T("ALT_2RSD LED"));
|
break;
|
case LightController_ALT_8RSDF:
|
strTemp.Format(_T("ALT_8RSDF LED"));
|
break;
|
case LightControl_LFusion_PDSeries:
|
strTemp.Format(_T("LFusion_PDSeries LED"));
|
break;
|
case LightController_ShinHan_TCP:
|
strTemp.Format(_T("ShinHan TCP LED"));
|
break;
|
|
default:
|
strTemp.Format(_T(""));
|
break;
|
}
|
|
strArrayOption.Add(strTemp);
|
}
|
m_ctrlGridLightInfo.SetCellType(nRowIdx, nColIdx, RUNTIME_CLASS(CGridCellCombo));
|
pCellCombo = (CGridCellCombo*)m_ctrlGridLightInfo.GetCell(nRowIdx, nColIdx);
|
pCellCombo->SetOptions(strArrayOption);
|
pCellCombo->SetStyle(CBS_DROPDOWN);
|
|
nColIdx++;
|
}
|
}
|
}
|
|
void CDlgSystemLight::ResetLightInfoGrid()
|
{
|
int i, j, nRowIdx, nColIdx;
|
CString strItemText;
|
CGridCellCheck* pCellCheck = NULL;
|
|
nRowIdx = 0;
|
nColIdx = 0;
|
strItemText = _T("");
|
|
for(i = 0; i < m_nLightCount; i++)
|
{
|
nRowIdx = 1;
|
nColIdx++;
|
|
for(j = 0; j < LIGHT_INFO_GRID_ROW_COUNT - 1; j++)
|
{
|
m_ctrlGridLightInfo.SetItemText(nRowIdx++, nColIdx, strItemText);
|
}
|
}
|
}
|
|
void CDlgSystemLight::UpdateDialogData(int nGantryIdx, int nHeaderIdx, int nLightCount)
|
{
|
m_nGantryIdx = nGantryIdx;
|
m_nHeaderIdx = nHeaderIdx;
|
m_nLightCount = nLightCount;
|
|
UpdateData(FALSE);
|
FillLightInfo();
|
m_ctrlGridLightInfo.Invalidate(FALSE);
|
}
|