// CPJsDlg.cpp: 实现文件
|
//
|
|
#include "pch.h"
|
#include "EAPSimulator.h"
|
#include "CPJsDlg.h"
|
#include "afxdialogex.h"
|
|
|
// CPJsDlg 对话框
|
|
IMPLEMENT_DYNAMIC(CPJsDlg, CDialogEx)
|
|
CPJsDlg::CPJsDlg(CWnd* pParent /*=nullptr*/)
|
: CDialogEx(IDD_DIALOG_PJS, pParent)
|
{
|
|
}
|
|
CPJsDlg::~CPJsDlg()
|
{
|
for (auto item : m_pjs) {
|
delete item;
|
}
|
m_pjs.clear();
|
}
|
|
void CPJsDlg::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialogEx::DoDataExchange(pDX);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CPJsDlg, CDialogEx)
|
ON_BN_CLICKED(IDC_BUTTON_ADD, &CPJsDlg::OnBnClickedButtonAdd)
|
ON_BN_CLICKED(IDC_BUTTON_DELETE, &CPJsDlg::OnBnClickedButtonDelete)
|
ON_BN_CLICKED(IDC_BUTTON_SEND, &CPJsDlg::OnBnClickedButtonSend)
|
END_MESSAGE_MAP()
|
|
|
// CPJsDlg 消息处理程序
|
|
|
void CPJsDlg::OnBnClickedButtonAdd()
|
{
|
// TODO: 在此添加控件通知处理程序代码
|
}
|
|
void CPJsDlg::OnBnClickedButtonDelete()
|
{
|
CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST1);
|
int nSel = pListCtrl->GetNextItem(-1, LVNI_SELECTED);
|
|
if (nSel != -1) {
|
SERVO::CProcessJob* pj = (SERVO::CProcessJob*)pListCtrl->GetItemData(nSel);
|
for (auto iter = m_pjs.begin(); iter != m_pjs.end(); ++iter) {
|
if (*iter == pj) {
|
delete (*iter);
|
m_pjs.erase(iter);
|
break;
|
}
|
}
|
}
|
|
pListCtrl->DeleteItem(nSel);
|
}
|
|
void CPJsDlg::OnBnClickedButtonSend()
|
{
|
theApp.m_model.m_pHsmsActive->hsmsPRJobMultiCreate(m_pjs);
|
}
|
|
BOOL CPJsDlg::OnInitDialog()
|
{
|
CDialogEx::OnInitDialog();
|
|
|
// 报表控件
|
CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST1);
|
DWORD dwStyle = pListCtrl->GetExtendedStyle();
|
dwStyle |= LVS_EX_FULLROWSELECT;
|
dwStyle |= LVS_EX_GRIDLINES;
|
pListCtrl->SetExtendedStyle(dwStyle);
|
|
HIMAGELIST imageList = ImageList_Create(24, 24, ILC_COLOR24, 1, 1);
|
ListView_SetImageList(pListCtrl->GetSafeHwnd(), imageList, LVSIL_SMALL);
|
pListCtrl->InsertColumn(0, _T(""), LVCFMT_RIGHT, 0);
|
pListCtrl->InsertColumn(1, _T("PJ ID"), LVCFMT_LEFT, 100);
|
pListCtrl->InsertColumn(2, _T("Carrier1 & Slots"), LVCFMT_LEFT, 180);
|
pListCtrl->InsertColumn(3, _T("Carrier2 & Slots"), LVCFMT_LEFT, 180);
|
pListCtrl->InsertColumn(4, _T("Carrier3 & Slots"), LVCFMT_LEFT, 180);
|
pListCtrl->InsertColumn(5, _T("Carrier4 & Slots"), LVCFMT_LEFT, 180);
|
pListCtrl->InsertColumn(6, _T("PPID"), LVCFMT_LEFT, 180);
|
|
|
|
// 创建用于测试的PJ
|
{
|
SERVO::CProcessJob* pj = new SERVO::CProcessJob("PJ0001");
|
std::vector<uint8_t> slots1{ 1, 2, 3 };
|
pj->addCarrier("Test-Cassette-001", slots1);
|
pj->setRecipe(SERVO::RecipeMethod::NoTuning, "P1001");
|
m_pjs.push_back(pj);
|
}
|
{
|
SERVO::CProcessJob* pj = new SERVO::CProcessJob("PJ0002");
|
std::vector<uint8_t> slots1{ 1, 3 };
|
pj->addCarrier("CID1002", slots1);
|
std::vector<uint8_t> slots2{ 1};
|
pj->addCarrier("CID1003", slots2);
|
pj->setRecipe(SERVO::RecipeMethod::NoTuning, "R002");
|
m_pjs.push_back(pj);
|
}
|
{
|
SERVO::CProcessJob* pj = new SERVO::CProcessJob("PJ0003");
|
std::vector<uint8_t> slots1{ 1, 2, 3, 5 };
|
pj->addCarrier("CID1004", slots1);
|
pj->setRecipe(SERVO::RecipeMethod::NoTuning, "P1001");
|
m_pjs.push_back(pj);
|
}
|
|
// 显示到报表中
|
for (auto item : m_pjs) {
|
AddPjToListCtrl(item);
|
}
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
// 异常: OCX 属性页应返回 FALSE
|
}
|
|
void CPJsDlg::AddPjToListCtrl(SERVO::CProcessJob* pj)
|
{
|
CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST1);
|
pListCtrl->InsertItem(0, _T(""));
|
pListCtrl->SetItemData(0, (DWORD_PTR)pj);
|
pListCtrl->SetItemText(0, 1, pj->id().c_str());
|
pListCtrl->SetItemText(0, 6, pj->recipeSpec().c_str());
|
|
auto carries = pj->carriers();
|
for (int i = 0; i < min(4, carries.size()); i++) {
|
pListCtrl->SetItemText(0, 2 + i, GetFormatString(carries[i])); ;
|
}
|
}
|
|
CString CPJsDlg::GetFormatString(SERVO::CarrierSlotInfo& csi)
|
{
|
CString strRet;
|
strRet.Append(csi.carrierId.c_str());
|
strRet.Append("<");
|
int size = min(8, csi.slots.size());
|
for (int i = 0; i < size; i++) {
|
strRet.Append(std::to_string(csi.slots[i]).c_str());
|
if (i != size - 1) {
|
strRet.Append(",");
|
}
|
}
|
strRet.Append(">");
|
|
return strRet;
|
}
|