// CPjPage1.cpp: 实现文件
|
//
|
|
#include "stdafx.h"
|
#include "Servo.h"
|
#include "CCjPage2.h"
|
#include "afxdialogex.h"
|
#include "RecipeManager.h"
|
|
|
// CPjPage1 对话框
|
|
IMPLEMENT_DYNAMIC(CCjPage2, CCjPageBase)
|
|
CCjPage2::CCjPage2(CWnd* pParent /*=nullptr*/)
|
: CCjPageBase(IDD_CJ_PAGE2, pParent)
|
{
|
|
}
|
|
CCjPage2::~CCjPage2()
|
{
|
}
|
|
void CCjPage2::DoDataExchange(CDataExchange* pDX)
|
{
|
CCjPageBase::DoDataExchange(pDX);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CCjPage2, CCjPageBase)
|
ON_WM_DESTROY()
|
ON_EN_CHANGE(IDC_EDIT_PJ_ID, &CCjPage2::OnEnChangeEditPjId)
|
ON_CBN_SELCHANGE(IDC_COMBO_RECIPE, &CCjPage2::OnCbnSelchangeComboRecipe)
|
ON_BN_CLICKED(IDC_RADIO1, &CCjPage2::OnBnClickedRadio1)
|
ON_BN_CLICKED(IDC_RADIO2, &CCjPage2::OnBnClickedRadio2)
|
ON_BN_CLICKED(IDC_RADIO3, &CCjPage2::OnBnClickedRadio3)
|
ON_BN_CLICKED(IDC_RADIO4, &CCjPage2::OnBnClickedRadio4)
|
END_MESSAGE_MAP()
|
|
|
// CPjPage1 消息处理程序
|
|
|
void CCjPage2::OnSetContext(void* pContext)
|
{
|
UpdatePjData();
|
}
|
|
void CCjPage2::SetExclusionNames(std::vector<std::string>& names)
|
{
|
m_exclusionNames = names;
|
}
|
|
BOOL CCjPage2::OnInitDialog()
|
{
|
CCjPageBase::OnInitDialog();
|
|
|
m_grid.SubclassDlgItem(IDC_GRID1, this);
|
m_grid.InitGrid(4, 8);
|
m_grid.SetColumnWidths(100, 220);
|
m_grid.SetRowHeight(28);
|
m_grid.SetHeaderHeight(32);
|
m_grid.EnableColumnResize(FALSE); // 禁止拖动列宽
|
|
m_grid.SetPortInfo(0, _T("Port 1"), _T(""));
|
m_grid.SetPortInfo(1, _T("Port 2"), _T(""));
|
m_grid.SetPortInfo(2, _T("Port 3"), _T(""));
|
m_grid.SetPortInfo(3, _T("Port 4"), _T(""));
|
|
|
UpdatePjData();
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
// 异常: OCX 属性页应返回 FALSE
|
}
|
|
void CCjPage2::OnDestroy()
|
{
|
CCjPageBase::OnDestroy();
|
|
// TODO: 在此处添加消息处理程序代码
|
}
|
|
void CCjPage2::Resize()
|
{
|
CCjPageBase::Resize();
|
|
|
CWnd* pItem;
|
CRect rcClient, rcItem;
|
GetClientRect(&rcClient);
|
pItem = GetDlgItem(IDC_GRID1);
|
pItem->GetWindowRect(&rcItem);
|
ScreenToClient(rcItem);
|
|
// 让控件窗口尺寸自动匹配当前列宽/行数(不出现滚动条)
|
if (::IsWindow(m_grid.m_hWnd)) {
|
CSize best = m_grid.CalcBestWindowSize(TRUE); // 计算到含非客户区的最终窗口大小
|
pItem->MoveWindow(rcItem.left, rcItem.top, best.cx, best.cy);
|
pItem->Invalidate();
|
}
|
}
|
|
void CCjPage2::OnApply()
|
{
|
//SERVO::CProcessJob*
|
if (m_pContext == nullptr) return;
|
SERVO::CProcessJob* pProcessJob = (SERVO::CProcessJob*)m_pContext;
|
|
// 更新名称
|
BOOL bOkName = TRUE;
|
char szBuffer[256];
|
GetDlgItemText(IDC_EDIT_PJ_ID, szBuffer, 256);
|
for (auto item : m_exclusionNames) {
|
if (item.compare(std::string(szBuffer)) == 0) {
|
bOkName = FALSE;
|
break;
|
}
|
}
|
if (!bOkName) {
|
AfxMessageBox("不能使用和其它Process Job相同的ID");
|
return;
|
}
|
|
|
pProcessJob->setId(std::string(szBuffer));
|
|
// 更新配方
|
CString strRecipe;
|
CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_RECIPE);
|
int idx = pComboBox->GetCurSel();
|
if (idx >= 0) {
|
pComboBox->GetLBText(idx, strRecipe);
|
#ifdef UNICODE
|
CT2A utf8Str(strRecipe, CP_UTF8);
|
std::string recipe(utf8Str);
|
#else
|
std::string recipe(strRecipe.GetString());
|
#endif
|
|
pProcessJob->setRecipe(SERVO::RecipeMethod::NoTuning, recipe);
|
}
|
|
|
ContentChanged(1);
|
}
|
|
void CCjPage2::UpdatePjData()
|
{
|
m_bContentChangedLock = TRUE;
|
|
CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_RECIPE);
|
pComboBox->ResetContent();
|
std::vector<std::string> vecRecipe = RecipeManager::getInstance().getAllPPID();
|
for (const auto& recipe : vecRecipe) {
|
pComboBox->AddString(CString(recipe.c_str()));
|
}
|
|
if (m_pContext) {
|
SERVO::CProcessJob* pProcessJob = (SERVO::CProcessJob*)m_pContext;
|
SetDlgItemText(IDC_EDIT_PJ_ID, pProcessJob->id().c_str());
|
int idx = pComboBox->FindStringExact(-1, pProcessJob->recipeSpec().c_str());
|
if (idx != CB_ERR) pComboBox->SetCurSel(idx);
|
}
|
|
// 示例:设置Port信息、锁列、填充Glass
|
/*
|
m_grid.SetPortInfo(0, _T("Port 1"), _T(""));
|
m_grid.SetPortInfo(1, _T("Port 2"), _T(""));
|
m_grid.SetPortInfo(2, _T("Port 3"), _T("Carrier C"));
|
m_grid.SetPortInfo(3, _T("Port 4"), _T("Carrier D"));
|
m_grid.SetPortAllocated(2, TRUE, _T("ProcessJob 1"));
|
m_grid.SetSlotGlass(0, 0, TRUE, _T("A00123"), CCarrierSlotGrid::MAT_G1);
|
m_grid.SetSlotGlass(0, 1, TRUE, _T("A00124"), CCarrierSlotGrid::MAT_G1);
|
*/
|
|
m_bContentChangedLock = FALSE;
|
}
|
|
void CCjPage2::OnEnChangeEditPjId()
|
{
|
ContentChanged(0);
|
}
|
|
void CCjPage2::OnCbnSelchangeComboRecipe()
|
{
|
ContentChanged(0);
|
}
|
|
void CCjPage2::OnBnClickedRadio1()
|
{
|
m_grid.SetPortAllocated(0, FALSE, _T(""));
|
m_grid.SetPortAllocated(1, TRUE, _T(""));
|
m_grid.SetPortAllocated(2, TRUE, _T(""));
|
m_grid.SetPortAllocated(3, TRUE, _T(""));
|
}
|
|
void CCjPage2::OnBnClickedRadio2()
|
{
|
m_grid.SetPortAllocated(0, TRUE, _T(""));
|
m_grid.SetPortAllocated(1, FALSE, _T(""));
|
m_grid.SetPortAllocated(2, TRUE, _T(""));
|
m_grid.SetPortAllocated(3, TRUE, _T(""));
|
}
|
|
void CCjPage2::OnBnClickedRadio3()
|
{
|
m_grid.SetPortAllocated(0, TRUE, _T(""));
|
m_grid.SetPortAllocated(1, TRUE, _T(""));
|
m_grid.SetPortAllocated(2, FALSE, _T(""));
|
m_grid.SetPortAllocated(3, TRUE, _T(""));
|
}
|
|
void CCjPage2::OnBnClickedRadio4()
|
{
|
m_grid.SetPortAllocated(0, TRUE, _T(""));
|
m_grid.SetPortAllocated(1, TRUE, _T(""));
|
m_grid.SetPortAllocated(2, TRUE, _T(""));
|
m_grid.SetPortAllocated(3, FALSE, _T(""));
|
}
|