机械手程序代码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

// countDlg.cpp : 实现文件
//
#include"stdafx.h"
#include"count.h"
#include"countDlg.h"
#include"stdafx.h"
#include"afxdialogex.h"
#include<cstring>
#include<cstringt.h>
#include<iostream>
#include"MyThreadPool.h"
#include"MyThread.h"
#include<iostream>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
using namespace std;
CTestTask::CTestTask(int id)
:CTask(id)
{
}
CTestTask::~CTestTask(void)
{
}
CMyThreadPool threadpool(10);
// 用于应用程序“关于”菜单项的 CAboutDlg 对话框
struct LinkingBoard1
{
BOOL listflag1;//板子测试位空闲标志 1为位空闲 0为忙碌BOOL listflag2;//板子测试位空闲标志 1为位空闲 0为忙碌BOOL listflag3;//板子测试位空闲标志 1为位空闲 0为忙碌
BOOL listflag4;//板子测试位空闲标志 1为位空闲 0为忙碌
int testresult1;//板子测试结果标志 8为PASS 6为FAIL 2为没有测试int testresult2;//板子测试结果标志 8为PASS 6为FAIL
int testresult3;//板子测试结果标志 8为PASS 6为FAIL
int testresult4;//板子测试结果标志 8为PASS 6为FAIL
BOOL board1;//工位有无测试板子标志
BOOL board2;//工位有无测试板子标志
BOOL board3;//工位有无测试板子标志
BOOL board4;//工位有无测试板子标志
CString disabled1;//工位不可用颜色
CString disabled2;//工位不可用颜色
CString disabled3;//工位不可用颜色
CString disabled4;//工位不可用颜色
BOOL stations1;//工位1是否可用
BOOL stations2;//工位2是否可用
BOOL stations3;//工位3是否可用
BOOL stations4;//工位4是否可用
BOOL testtostation1;//工位是否执行测试标志
BOOL testtostation2;//工位是否执行测试标志
BOOL testtostation3;//工位是否执行测试标志
BOOL testtostation4;//工位是否执行测试标志
int current1;//板子测试位正在测试的板子编号
int current2;//板子测试位正在测试的板子编号
int current3;//板子测试位正在测试的板子编号
int current4;//板子测试位正在测试的板子编号
BOOL testing1;//测试板子完成标志 0正在测试 1测试完成
BOOL testing2;//测试板子完成标志 0正在测试 1测试完成
BOOL testing3;//测试板子完成标志 0正在测试 1测试完成
BOOL testing4;//测试板子完成标志 0正在测试 1测试完成
int test1;//抓板子到工位的标志用于最后不显示重复测试
int test2;//抓板子到工位的标志用于最后不显示重复测试
int test3;//抓板子到工位的标志用于最后不显示重复测试
int test4;//抓板子到工位的标志用于最后不显示重复测试
int pfail1;//抓板子到PASS FAIL的标志用于最后不显示重复测试
int pfail2;//抓板子到PASS FAIL的标志用于最后不显示重复测试
BOOL pfail3;//抓板子到PASS FAIL的标志用于最后不显示重复测试
BOOL pfail4;//抓板子到PASS FAIL的标志用于最后不显示重复测试
BOOL ready1;//字据工位是否准备好拿去测试 1为准备好 0为未准备好
BOOL ready2;//字据工位是否准备好拿去测试 1为准备好 0为未准备好
BOOL ready3;//字据工位是否准备好拿去测试 1为准备好 0为未准备好
BOOL ready4;//字据工位是否准备好拿去测试 1为准备好 0为未准备好
BOOL readdy1;//工位是否准备好拿走到pass or fail 1为准备好 0为未准备好BOOL readdy2;//工位是否准备好拿走到pass or fail 1为准备好 0为未准备好BOOL readdy3;//工位是否准备好拿走到pass or fail 1为准备好 0为未准备好BOOL readdy4;//工位是否准备好拿走到pass or fail 1为准备好 0为未准备好
};
struct B
{
int count1;//字据1提供的工位数
int count2;//字据2提供的工位数
int count3;//字据3提供的工位数
int count4;//字据4提供的工位数
int conduct1;//执行切割板测试
int conduct2;//执行切割板测试
int conduct3;//执行切割板测试
int conduct4;//执行切割板测试
BOOL linkingboard;//测试板子是否是连板的标志,1连板,0为切割板
BOOL station1;//字据1是否可用
BOOL station2;//字据2是否可用
BOOL station3;//字据3是否可用
BOOL station4;//字据4是否可用
int unt;
int ttp;//提供的字据数进行判断
int testresult1;//板子测试结果标志 8为PASS 6为FAIL 2为没有测试
int testresult2;//板子测试结果标志 8为PASS 6为FAIL 2为没有测试
int testresult3;//板子测试结果标志 8为PASS 6为FAIL 2为没有测试
int testresult4;//板子测试结果标志 8为PASS 6为FAIL 2为没有测试
BOOL linkflag1;//连板字据1是否空闲
BOOL linkflag2;//连板字据2是否空闲
BOOL linkflag3;//连板字据3是否空闲
BOOL linkflag4;//连板字据4是否空闲
BOOL linktesting1;//连接测试板子测试完成标志 0正在测试 1测试完成BOOL linktesting2;//连接测试板子测试完成标志 0正在测试 1测试完成BOOL linktesting3;//连接测试板子测试完成标志 0正在测试 1测试完成BOOL linktesting4;//连接测试板子测试完成标志 0正在测试 1测试完成
BOOL ready1;//字据工位是否准备好拿去测试 1为准备好 0为未准备好
BOOL ready2;//字据工位是否准备好拿去测试 1为准备好 0为未准备好
BOOL ready3;//字据工位是否准备好拿去测试 1为准备好 0为未准备好
BOOL ready4;//字据工位是否准备好拿去测试 1为准备好 0为未准备好
BOOL readdy1;//工位是否准备好拿走到pass or fail 1为准备好 0为未准备好BOOL readdy2;//工位是否准备好拿走到pass or fail 1为准备好 0为未准备好BOOL readdy3;//工位是否准备好拿走到pass or fail 1为准备好 0为未准备好BOOL readdy4;//工位是否准备好拿走到pass or fail 1为准备好 0为未准备好
int current1;//板子测试位正在测试的板子编号
int current2;//板子测试位正在测试的板子编号
int current3;//板子测试位正在测试的板子编号
int current4;//板子测试位正在测试的板子编号
int testedd1;//否执行抓取测试
int testedd2;//是否执行抓取测试
int testedd3;//是否执行抓取测试
int testedd4;//是否执行抓取测试
int tested1;//是否执行抓取测试抓取到PASS fail
int tested2;//是否执行抓取测试抓取到PASS fail
int tested3;//是否执行抓取测试抓取到PASS fail
int tested4;//是否执行抓取测试抓取到PASS fail
BOOL cap1;//1和好 0打开
BOOL cap2;//1和好 0打开
BOOL cap3;//1和好 0打开
BOOL cap4;//1和好 0打开
BOOL m_station1;//执行工位测试标志
BOOL m_station2;//执行工位测试标志
BOOL m_station3;//执行工位测试标志
BOOL m_station4;//执行工位测试标志
int grab1;//反复测试,抓取板子数量到pass或者fail的总数等于字据数量才可以进行抓取测试int grab2;//反复测试,抓取板子数量到pass或者fail的总数等于字据数量才可以进行抓取测试int grab3;//反复测试,抓取板子数量到pass或者fail的总数等于字据数量才可以进行抓取测试int grab4;//反复测试,抓取板子数量到pass或者fail的总数等于字据数量才可以进行抓取测试
LinkingBoard1 LB[4];
BOOL machinehand;//机械手是否空闲 1为空闲 0处于占用状态
int stop;
BOOL link;//执行连板或切割板标志,1为连板 0为切割板
};
B b;
class CAboutDlg : public CDialogEx
{
public:
CAboutDlg();
// 对话框数据
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
// CcountDlg 对话框
CcountDlg::CcountDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CcountDlg::IDD, pParent)
, m_count(0)
, m_current(0)
, m_list1(0)
, m_list2(0)
, m_list3(0)
, m_list4(0)
, m_pass(0)
, m_fail(0)
, m_list5(0)
, m_list6(0)
, m_list7(0)
, m_list8(0)
, m_list9(0)
, m_list10(0)
, m_list11(0)
, m_list12(0)
, m_list13(0)
, m_list14(0)
, m_list15(0)
, m_list16(0)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_disabled.CreateSolidBrush(RGB(0, 0, 0));
}
void CcountDlg::DoDataExchange(CDataExchange* pDX) {
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_count);
DDX_Text(pDX, IDC_EDIT2, m_current);
DDX_Text(pDX, IDC_LIST1, m_list1);
DDX_Text(pDX, IDC_LIST2, m_list2);
DDX_Text(pDX, IDC_LIST3, m_list3);
DDX_Text(pDX, IDC_LIST4, m_list4);
DDX_Text(pDX, IDC_PASS, m_pass);
DDX_Text(pDX, IDC_FAIL, m_fail);
DDX_Text(pDX, IDC_LIST5, m_list5);
DDX_Text(pDX, IDC_LIST6, m_list6);
DDX_Text(pDX, IDC_LIST7, m_list7);
DDX_Text(pDX, IDC_LIST8, m_list8);
DDX_Text(pDX, IDC_LIST9, m_list9);
DDX_Text(pDX, IDC_LIST10, m_list10);
DDX_Text(pDX, IDC_LIST11, m_list11);
DDX_Text(pDX, IDC_LIST12, m_list12);
DDX_Text(pDX, IDC_LIST13, m_list13);
DDX_Text(pDX, IDC_LIST14, m_list14);
DDX_Text(pDX, IDC_LIST15, m_list15);
DDX_Text(pDX, IDC_LIST16, m_list16);
DDX_Control(pDX, IDC_LIST17, m_list17);
DDX_Control(pDX, IDC_LIST18, m_list18);
DDX_Control(pDX, IDC_LIST19, m_list19);
DDX_Control(pDX, IDC_LIST20, m_list20);
}
BEGIN_MESSAGE_MAP(CcountDlg, CDialogEx)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_EN_CHANGE(IDC_EDIT1, &CcountDlg::OnEnChangeEdit1)
ON_BN_CLICKED(IDC_BUTTON1, &CcountDlg::OnBnClickedButton1) ON_WM_CTLCOLOR()
ON_WM_SIZE()
END_MESSAGE_MAP()
// CcountDlg 消息处理程序
BOOL CcountDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
//((CEdit*)GetDlgItem(IDC_EDIT1))->SetLimitText(3);
// 将“关于...”菜单项添加到系统菜单中。

// IDM_ABOUTBOX 必须在系统命令范围内。

ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 设置此对话框的图标。

当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
// TODO: 在此添加额外的初始化代码
// TODO: 在此添加额外的初始化代码
CRect rect;
// 获取编程语言列表视图控件的位置和大小
m_list17.GetClientRect(&rect);
m_list18.GetClientRect(&rect);
m_list19.GetClientRect(&rect);
m_list20.GetClientRect(&rect);
// 为列表视图控件添加全行选中和栅格风格
m_list17.SetExtendedStyle(m_list17.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
m_list18.SetExtendedStyle(m_list18.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
m_list19.SetExtendedStyle(m_list19.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
m_list20.SetExtendedStyle(m_list20.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
// 为列表视图控件添加三列
m_list17.InsertColumn(0, _T("Test Station"), LVCFMT_CENTER,rect.Width()/2, 1);
m_list17.InsertColumn(1, _T("Test Item"), LVCFMT_CENTER, rect.Width()/2, 1);
m_list18.InsertColumn(0, _T("Test Station"), LVCFMT_CENTER, rect.Width()/2, 0);
m_list18.InsertColumn(1, _T("Test Item"), LVCFMT_CENTER, rect.Width()/2, 1);
m_list19.InsertColumn(0, _T("Test Station"), LVCFMT_CENTER, rect.Width()/2, 0);
m_list19.InsertColumn(1, _T("Test Item"), LVCFMT_CENTER, rect.Width()/2, 1);
m_list20.InsertColumn(0, _T("Test Station"), LVCFMT_CENTER, rect.Width()/2, 0);
m_list20.InsertColumn(1, _T("Test Item"), LVCFMT_CENTER, rect.Width()/2, 1);
b.conduct1=0;
b.conduct2=0;
b.conduct3=0;
b.conduct4=0;
//读取配置文档
CString FilePath;
//NULL 一个模块的句柄。

可以是一个DLL模块,或者是一个应用程序的实例句柄。

如果该参数为NULL该函数返回该应用程序全路径
//FilePath.GetBufferSetLength指定一个字串缓冲区
//装载到缓冲区FilePath.GetBufferSetLength的最大字符数量
GetModuleFileName(NULL,FilePath.GetBufferSetLength(MAX_PATH+1),MAX_PATH);
int n;
//在一个较大的字符串中从末端开始查找本地目录字符,返回位置
n=FilePath.ReverseFind('\\');
//从左侧截取当前相对路径
FilePath=FilePath.Left(n);
//当前绝对路径为测试计划NTG_55TestPlan.txt的位置
FilePath += "\\configuration_document.ini";
b.linkingboard=GetPrivateProfileInt(L"CUSTOM",L"Linkingboard",888,FilePath);
if(b.linkingboard==888 )
{
CString str;
str="Reading configuration document “Linkingboard” is Error";
AfxMessageBox(str);
}
if(b.linkingboard==1)//连板
{
GetLinkCount(FilePath);
}
else//if(b.linkingboard==0) //不是连板
{
GetNoLinkCount(FilePath);
}
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
//获取连板字据容量
void CcountDlg::GetLinkCount(CString FilePath)
{
b.station1=GetPrivateProfileInt(L"CUSTOM",L"station1",888,FilePath);
if(b.station1)
{
b.linkflag1=1;//连板字据1空闲
}
b.station2=GetPrivateProfileInt(L"CUSTOM",L"station2",888,FilePath);
if(b.station2)
{
b.linkflag2=1;//连板字据1可用
}
b.station3=GetPrivateProfileInt(L"CUSTOM",L"station3",888,FilePath);
if(b.station3)
{
b.linkflag3=1;//连板字据1可用
}
b.station4=GetPrivateProfileInt(L"CUSTOM",L"station4",888,FilePath);
if(b.station4)
{
b.linkflag4=1;//连板字据1可用
}
b.link=1;
}
//获取切割板字据容量
void CcountDlg::GetNoLinkCount(CString FilePath)
{
b.ttp=0;
b.unt=GetPrivateProfileInt(L"CUSTOM",L"LocationNumber",888,FilePath);
if(888==b.unt)
AfxMessageBox(L"Get number location error");
b.station1=GetPrivateProfileInt(L"CUSTOM",L"station1",888,FilePath);
if(b.station1)//字据1可用设置容量
{
b.ttp++;
b.count1=GetPrivateProfileInt(L"CUSTOM",L"count1",888,FilePath);
if(b.count1==888) AfxMessageBox(L"Access to location1 data error");
int i=0;
b.LB[0].stations1=GetPrivateProfileInt(L"CUSTOM",L"listflag1.1",888,FilePath);
if(1==b.LB[0].stations1)
{
i++;
b.LB[0].ready1=1;
}
else b.LB[0].disabled1="Disabled";
b.LB[0].stations2=GetPrivateProfileInt(L"CUSTOM",L"listflag1.2",888,FilePath);
if(1==b.LB[0].stations2)
{
i++;
b.LB[0].ready2=1;
}
else b.LB[0].disabled2="Disabled";
b.LB[0].stations3=GetPrivateProfileInt(L"CUSTOM",L"listflag1.3",888,FilePath);
if(1==b.LB[0].stations3)
{
i++;
b.LB[0].ready3=1;
}
else b.LB[0].disabled3="Disabled";
b.LB[0].stations4=GetPrivateProfileInt(L"CUSTOM",L"listflag1.4",888,FilePath);
if(1==b.LB[0].stations4)
{
i++;
b.LB[0].ready4=1;
}
else b.LB[0].disabled4="Disabled";
if(b.count1!=i)
AfxMessageBox(L"The Station1 allocation is defeated");
}
else
{
b.count1=0;//不可用设置容量为0
b.LB[0].disabled1="Disabled";
b.LB[0].disabled2="Disabled";
b.LB[0].disabled3="Disabled";
b.LB[0].disabled4="Disabled";
}
b.station2=GetPrivateProfileInt(L"CUSTOM",L"station2",888,FilePath);
if(b.station2) //字据2可用设置容量
{
b.ttp++;
b.count2=GetPrivateProfileInt(L"CUSTOM",L"count2",888,FilePath);
int i=0;
b.LB[1].stations1=GetPrivateProfileInt(L"CUSTOM",L"listflag2.1",888,FilePath);
if(1==b.LB[1].stations1)
{
i++;
b.LB[1].ready1=1;
}
else b.LB[1].disabled1="Disabled";
b.LB[1].stations2=GetPrivateProfileInt(L"CUSTOM",L"listflag2.2",888,FilePath);
if(1==b.LB[1].stations2)
{
i++;
b.LB[1].ready2=1;
}
else b.LB[1].disabled2="Disabled";
b.LB[1].stations3=GetPrivateProfileInt(L"CUSTOM",L"listflag2.3",888,FilePath);
if(1==b.LB[1].stations3)
{
i++;
b.LB[1].ready3=1;
}
else b.LB[1].disabled3="Disabled";
b.LB[1].stations4=GetPrivateProfileInt(L"CUSTOM",L"listflag2.4",888,FilePath);
if(1==b.LB[1].stations4)
{
i++;
b.LB[1].ready4=1;
}
else b.LB[1].disabled4="Disabled";
if(b.count2!=i)
AfxMessageBox(L"The Station2 allocation is defeated");
}
else
{
b.count2=0;//不可用设置容量为0
b.LB[1].disabled1="Disabled";
b.LB[1].disabled2="Disabled";
b.LB[1].disabled3="Disabled";
b.LB[1].disabled4="Disabled";
}
b.station3=GetPrivateProfileInt(L"CUSTOM",L"station3",888,FilePath);
if(b.station3)
{
b.ttp++;
b.count3=GetPrivateProfileInt(L"CUSTOM",L"count3",888,FilePath);
int i=0;
b.LB[2].stations1=GetPrivateProfileInt(L"CUSTOM",L"listflag3.1",888,FilePath);
if(1==b.LB[2].stations1)
{
i++;
b.LB[2].ready1=1;
}
else b.LB[2].disabled1="Disabled";
b.LB[2].stations2=GetPrivateProfileInt(L"CUSTOM",L"listflag3.2",888,FilePath);
if(1==b.LB[2].stations2)
{
i++;
b.LB[2].ready2=1;
}
else b.LB[2].disabled2="Disabled";
b.LB[2].stations3=GetPrivateProfileInt(L"CUSTOM",L"listflag3.3",888,FilePath);
if(1==b.LB[2].stations3)
{
i++;
b.LB[2].ready3=1;
}
else b.LB[2].disabled3="Disabled";
b.LB[2].stations4=GetPrivateProfileInt(L"CUSTOM",L"listflag3.4",888,FilePath);
if(1==b.LB[2].stations4)
{
i++;
b.LB[2].ready4=1;
}
else b.LB[2].disabled4="Disabled";
if(b.count3!=i)
AfxMessageBox(L"The Station3 allocation is defeated");
}
else
{
b.count3=0;//不可用设置容量为0
b.LB[2].disabled1="Disabled";
b.LB[2].disabled2="Disabled";
b.LB[2].disabled3="Disabled";
b.LB[2].disabled4="Disabled";
}
b.station4=GetPrivateProfileInt(L"CUSTOM",L"station4",888,FilePath);
if(b.station4)
{
b.ttp++;
b.count4=GetPrivateProfileInt(L"CUSTOM",L"count4",888,FilePath);
int i=0;
b.LB[3].stations1=GetPrivateProfileInt(L"CUSTOM",L"listflag4.1",888,FilePath);
if(1==b.LB[3].stations1)
{
i++;
b.LB[3].ready1=1;
}
else b.LB[3].disabled1="Disabled";
b.LB[3].stations2=GetPrivateProfileInt(L"CUSTOM",L"listflag4.2",888,FilePath);
if(1==b.LB[3].stations2)
{
i++;
b.LB[3].ready2=1;
}
else b.LB[3].disabled2="Disabled";
b.LB[3].stations3=GetPrivateProfileInt(L"CUSTOM",L"listflag4.3",888,FilePath);
if(1==b.LB[3].stations3)
{
i++;
b.LB[3].ready3=1;
}
else b.LB[3].disabled3="Disabled";
b.LB[3].stations4=GetPrivateProfileInt(L"CUSTOM",L"listflag4.4",888,FilePath);
if(1==b.LB[3].stations4)
{
i++;
b.LB[3].ready4=1;
}
else b.LB[3].disabled4="Disabled";
if(b.count4!=i)
AfxMessageBox(L"The Station4 allocation is defeated");
}
else
{
b.count4=0;//不可用设置容量为0
b.LB[3].disabled1="Disabled";
b.LB[3].disabled2="Disabled";
b.LB[3].disabled3="Disabled";
b.LB[3].disabled4="Disabled";
}
if(b.ttp!=b.unt)
AfxMessageBox(L"Location number and the actual do not match");
b.link=0;
}
void CcountDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialogEx::OnSysCommand(nID, lParam);
}
}
// 如果向对话框添加最小化按钮,则需要下面的代码
// 来绘制该图标。

对于使用文档/视图模型的 MFC 应用程序,
// 这将由框架自动完成。

void CcountDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // 用于绘制的设备上下文
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 使图标在工作区矩形中居中
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// 绘制图标
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialogEx::OnPaint();
}
}
//当用户拖动最小化窗口时系统调用此函数取得光标
//显示。

HCURSOR CcountDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CcountDlg::OnEnChangeEdit1()
{
// TODO: 如果這是 RICHEDIT 控制項,控制項將不會
// 傳送此告知,除非您覆寫 CDialogEx::OnInitDialog() // 函式和呼叫 CRichEditCtrl().SetEventMask()
// 讓具有 ENM_CHANGE 旗標 ORed 加入遮罩。

// TODO: 在此加入控制項告知處理常式程式碼
}
bool DoEvents()
{
MSG msg;
while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT)
{
return false;
}
if (!AfxGetApp()->PreTranslateMessage(&msg))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
}
return true;
}
void CcountDlg::OnBnClickedButton1()
{
m_list17.DeleteAllItems();
m_list18.DeleteAllItems();
m_list19.DeleteAllItems();
m_list20.DeleteAllItems();
// TODO: 在此加入控制項告知處理常式程式碼
CString yy;
GetDlgItem(IDC_EDIT1)->GetWindowText(yy);
int cou;
cou=_ttoi(yy);
if(cou>0)
{
m_current=1;
}
else
{
m_current=0;
}
b.ready1=1;//字据工位是否准备好拿去测试 1为准备好 0为未准备好b.ready2=1;
b.ready3=1;
b.ready4=1;
b.LB[0].testresult1=2;
b.LB[0].testresult2=2;
b.LB[0].testresult3=2;
b.LB[0].testresult4=2;
b.testresult1=2;
b.LB[1].testresult1=2;
b.LB[1].testresult2=2;
b.LB[1].testresult3=2;
b.LB[1].testresult4=2;
b.testresult2=2;
b.LB[2].testresult1=2;
b.LB[2].testresult2=2;
b.LB[2].testresult3=2;
b.LB[2].testresult4=2;
b.testresult3=2;
b.LB[3].testresult1=2;
b.LB[3].testresult2=2;
b.LB[3].testresult3=2;
b.LB[3].testresult4=2;
b.testresult4=2;
b.linkflag1=1;//连板字据1是否空闲
b.linkflag2=1;
b.linkflag3=1;
b.linkflag4=1;
b.linkflag1=1;//连板字据1是否可用
b.linkflag2=1;//连板字据1是否可用
b.linkflag3=1;//连板字据1是否可用
b.linkflag4=1;//连板字据1是否可用
b.LB[0].listflag1=1;//工位空闲
b.LB[0].listflag2=1;//工位空闲
b.LB[0].listflag3=1;//工位空闲
b.LB[0].listflag4=1;//工位空闲
b.LB[1].listflag1=1;//工位空闲
b.LB[1].listflag2=1;//工位空闲
b.LB[1].listflag3=1;//工位空闲
b.LB[1].listflag4=1;//工位空闲
b.LB[2].listflag1=1;//工位空闲
b.LB[2].listflag2=1;//工位空闲
b.LB[2].listflag3=1;//工位空闲
b.LB[2].listflag4=1;//工位空闲
b.LB[3].listflag1=1;//工位空闲
b.LB[3].listflag2=1;//工位空闲
b.LB[3].listflag3=1;//工位空闲
b.LB[3].listflag4=1;//工位空闲
b.machinehand=1;
//b.LB[0].ready1=0;
b.machinehand=1;//机械手处于空闲状态SetDlgItemInt(IDC_EDIT2,m_current); DoEvents();
if(1==b.LB[0].stations1)
{
SetDlgItemInt(IDC_LIST1,0);
DoEvents();
}
if(1==b.LB[0].stations2)
{
SetDlgItemInt(IDC_LIST2,0);
DoEvents();
}
if(1==b.LB[0].stations3)
{
SetDlgItemInt(IDC_LIST3,0);
DoEvents();
}
if(1==b.LB[0].stations4)
{
SetDlgItemInt(IDC_LIST4,0);
DoEvents();
}
if(1==b.LB[1].stations1)
{
SetDlgItemInt(IDC_LIST5,0);
DoEvents();
}
if(1==b.LB[1].stations2)
{
SetDlgItemInt(IDC_LIST6,0);
DoEvents();
}
if(1==b.LB[1].stations3)
{
SetDlgItemInt(IDC_LIST7,0);
DoEvents();
}
if(1==b.LB[1].stations4)
{
SetDlgItemInt(IDC_LIST8,0);
DoEvents();
}
if(1==b.LB[2].stations1)
{
SetDlgItemInt(IDC_LIST9,0);
DoEvents();
}
if(1==b.LB[2].stations2)
{
SetDlgItemInt(IDC_LIST10,0);
DoEvents();
}
if(1==b.LB[2].stations3)
{
SetDlgItemInt(IDC_LIST11,0);
DoEvents();
}
if(1==b.LB[2].stations4)
{
SetDlgItemInt(IDC_LIST12,0);
DoEvents();
}
if(1==b.LB[3].stations1)
{
SetDlgItemInt(IDC_LIST13,0);
DoEvents();
}
if(1==b.LB[3].stations2)
{
SetDlgItemInt(IDC_LIST14,0);
DoEvents();
}
if(1==b.LB[3].stations3)
{
SetDlgItemInt(IDC_LIST15,0);
DoEvents();
}
if(1==b.LB[3].stations4)
{
SetDlgItemInt(IDC_LIST16,0);
DoEvents();
}
SetDlgItemInt(IDC_PASS,0); DoEvents();
SetDlgItemInt(IDC_FAIL,0); DoEvents();
b.stop=0;
b.LB[0].testresult1=2;
b.LB[0].testresult2=2;
b.LB[0].testresult3=2;
b.LB[0].testresult4=2;
b.testresult1=2;
b.LB[1].testresult1=2;
b.LB[1].testresult2=2;
b.LB[1].testresult3=2;
b.LB[1].testresult4=2;
b.testresult2=2;
b.LB[2].testresult1=2;
b.LB[2].testresult2=2;
b.LB[2].testresult3=2;
b.LB[2].testresult4=2;
b.testresult3=2;
b.LB[3].testresult1=2;
b.LB[3].testresult2=2;
b.LB[3].testresult3=2;
b.LB[3].testresult4=2;
b.testresult4=2;
while(b.stop!=cou)//输入板子数量与执行板子测试数量{
if(cou!=0)
{
StartTestLink(b.link);
}
}
if(b.stop==cou)
{
if(b.station1)
{
m_list17.InsertItem(0, _T("Test Over"));
m_list17.SetItemText(0, 1, _T("Over"));
m_list17.SetFocus(); //选中为焦点
m_list17.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
}
if(b.station2)
{
m_list18.InsertItem(0, _T("Test Over"));
m_list18.SetItemText(0, 1, _T("Over"));
m_list18.SetFocus(); //选中为焦点
m_list18.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
}
if(b.station3)
{
m_list19.InsertItem(0, _T("Test Over"));
m_list19.SetItemText(0, 1, _T("Over"));
m_list19.SetFocus(); //选中为焦点
m_list19.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
}
if(b.station4)
{
m_list20.InsertItem(0, _T("Test Over"));
m_list20.SetItemText(0, 1, _T("Over"));
m_list20.SetFocus(); //选中为焦点
m_list20.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
}
AfxMessageBox(L"OVER");
}
}
void CcountDlg::StartTestLink(bool link)
{
if(link==1)
StartLinkTest();
else
StartTest();
}
//开始连接板测试
void CcountDlg::StartLinkTest()
{
CString xx;
GetDlgItem(IDC_EDIT1)->GetWindowText(xx);
int str=_ttoi(xx);
if(str>=1)
{
if(GudgeLinkStation())
{
IdleLinkStation();
}
else
{
FullLinkStation();
}
}
}
//开始切割板测试
void CcountDlg::StartTest()
{
CString xx;
GetDlgItem(IDC_EDIT1)->GetWindowText(xx);
int str=_ttoi(xx);
if(str>=1)
{
if(GudgeStation())
{
IdleStation();
}
}
}
//判断连接板是否有空闲字据
BOOL CcountDlg::GudgeLinkStation()
{
if( b.LB[0].listflag1 || b.LB[1].listflag2 || b.LB[2].listflag3 || b.LB[3].listflag4 ){
return TRUE;
}
else {
return FALSE;
}
}
//切割板字据可用不可用
BOOL CcountDlg::GudgeStation()
{
if( b.station1 || b.station2 || b.station3 || b.station4 ) {
return TRUE;
}
else
{
return FALSE;
}
}
//字据满载
void CcountDlg::FullLinkStation()
{
if(m_current>=1)
{
IdleLinkStationNo(1);
IdleLinkStationNo(2);
IdleLinkStationNo(3);
IdleLinkStationNo(4);
}
}
//存在空闲连接板字据
void CcountDlg::IdleLinkStation()
{
CString xx;
GetDlgItem(IDC_EDIT1)->GetWindowText(xx);
int num;
num=_ttoi(xx);
if(m_current>=1)
{
if(b.station1)//字据可用
{
if(b.linkflag1)//空闲
{
if(b.machinehand && (m_current<=num))//机械手空闲且有待测板子
{//机械手空闲
SetDlgItemInt(IDC_EDIT2,m_current);
DoEvents();
IdleLinkStationHave(1);
}
else//字据空闲,没有板子
{
IdleLinkNo(1);
}
}
else
{
b.current1=m_current;
IdleLinkStationNo(1);
}
}
if(b.station2)//字据可用
{
if(b.linkflag2)//空闲
{
if(b.machinehand && (m_current<=num))//机械手空闲且有待测板子
{//机械手空闲
SetDlgItemInt(IDC_EDIT2,m_current);
DoEvents();
IdleLinkStationHave(2);
}
else//字据空闲,没有板子
{
IdleLinkNo(2);
}
}
else
{
b.current2=m_current;
IdleLinkStationNo(2);
}
}
if(b.station3)//字据可用
{
if(b.linkflag3)//空闲
{
if(b.machinehand && (m_current<=num))//机械手空闲且有待测板子
{//机械手空闲
SetDlgItemInt(IDC_EDIT2,m_current);
DoEvents();
IdleLinkStationHave(3);
}
else//字据空闲,没有板子
{
IdleLinkNo(3);
}
}
else
{
b.current3=m_current;
IdleLinkStationNo(3);
}
}
if(b.station4)//字据可用
{
if(b.linkflag4)//空闲
{
if(b.machinehand && (m_current<=num))//机械手空闲且有待测板子
{//机械手空闲
SetDlgItemInt(IDC_EDIT2,m_current);
DoEvents();
IdleLinkStationHave(4);
}
else//字据空闲,没有板子
{
IdleLinkNo(4);
}
}
else
{
b.current4=m_current;
IdleLinkStationNo(4);
}
}
}
}
//空闲的工位
void CcountDlg::IdleStation(int idl)
{
switch (idl)
{
case 1:
if(b.LB[0].listflag1)//工位1.1空闲
{
CString xx;
GetDlgItem(IDC_EDIT1)->GetWindowText(xx);
int num;
num=_ttoi(xx);
if(b.machinehand && (m_current<=num))//工位1可用机械手空闲且有待测板子
{//机械手空闲
SetDlgItemInt(IDC_EDIT2,m_current);
DoEvents();
IdleStationHave(1);//抓取板子放工位
}
}
break;
case 2:
if(b.LB[0].listflag2)//工位1.2空闲
{
CString xx;
GetDlgItem(IDC_EDIT1)->GetWindowText(xx);
int num;
num=_ttoi(xx);
if(b.machinehand && (m_current<=num))//工位1可用机械手空闲且有待测板子
{//机械手空闲
SetDlgItemInt(IDC_EDIT2,m_current);
DoEvents();
IdleStationHave(2);
}
}
break;
case 3:
if(b.LB[0].listflag3)//工位1.4空闲
{
CString xx;
GetDlgItem(IDC_EDIT1)->GetWindowText(xx);
int num;
num=_ttoi(xx);
if(b.machinehand && (m_current<=num))//工位1可用机械手空闲且有待测板子
{//机械手空闲
SetDlgItemInt(IDC_EDIT2,m_current);
DoEvents();
IdleStationHave(3);
}
}
break;
case 4:
if(b.LB[0].listflag4)//工位1.4空闲
{
CString xx;
GetDlgItem(IDC_EDIT1)->GetWindowText(xx);
int num;
num=_ttoi(xx);
if(b.machinehand && (m_current<=num))//工位1可用机械手空闲且有待测板子
{//机械手空闲
SetDlgItemInt(IDC_EDIT2,m_current);
DoEvents();
IdleStationHave(4);
}
}
break;
case 5:
if(b.LB[1].listflag1)//工位2.1空闲
{
CString xx;
GetDlgItem(IDC_EDIT1)->GetWindowText(xx);
int num;
num=_ttoi(xx);
if(b.machinehand && (m_current<=num))//工位1可用机械手空闲且有待测板子
{//机械手空闲
SetDlgItemInt(IDC_EDIT2,m_current);
DoEvents();
IdleStationHave(5);
}
}
break;
case 6:
if(b.LB[1].listflag2)//工位2.2空闲
{
CString xx;
GetDlgItem(IDC_EDIT1)->GetWindowText(xx);
int num;
num=_ttoi(xx);
if(b.machinehand && (m_current<=num))//工位1可用机械手空闲且有待测板子
{//机械手空闲
SetDlgItemInt(IDC_EDIT2,m_current);
DoEvents();
IdleStationHave(6);
}
}
break;
case 7:
if(b.LB[1].listflag3)//工位2.3空闲
{
CString xx;
GetDlgItem(IDC_EDIT1)->GetWindowText(xx);
int num;
num=_ttoi(xx);
if(b.machinehand && (m_current<=num))//工位1可用机械手空闲且有待测板子
{//机械手空闲
SetDlgItemInt(IDC_EDIT2,m_current);
DoEvents();
IdleStationHave(7);
}
}
break;。

相关文档
最新文档