📄 checkdlg.cpp
字号:
array.RemoveAll();
array.SetSize(1);
array.SetAt(0,0x06);
m_Com.SetOutput(COleVariant(array));
//////////////////////////////数据校验
/* if(t1=="-C"||t1=="C"||t1=="-c"||t1=="c")
{
AfxMessageBox("1号探头数据有错误,请校验!");
if(bauto==true)
this->OnAutocheckend();
else
this->OnMancheck5();
return;
}
if(t2=="-C"||t2=="C"||t2=="-c"||t2=="c")
{
AfxMessageBox("2号探头数据有错误,请校验!");
if(bauto==true)
this->OnAutocheckend();
else
this->OnMancheck5();
return;
}
if(t3=="-C"||t3=="C"||t3=="-c"||t3=="c")
{
AfxMessageBox("3号探头数据有错误,请校验!");
if(bauto==true)
this->OnAutocheckend();
else
this->OnMancheck5();
return;
}
*/
////////////////////////数据处理
ft1=atof(t1)/1000;
ft2=atof(t2)/1000;
ft3=atof(t3)/1000;
float pinpitch=15.24;
float PI=3.14159;
float tan_alpha=-(ft3-ft2)/(sqrt(pinpitch*pinpitch-(ft3-ft2)*(ft3-ft2)));
float alpha=atan(tan_alpha);
alpha=(alpha*180)/PI;
alpha=alpha*60;
/////////////////////////////
// m_T1Edit.Format("%.3f",ft1);
// m_T2Edit.Format("%.3f",ft2);
// m_T3Edit.Format("%.3f",alpha);
/////////////////////////////
if(bChangePos==true)
{
m_Progress_T1.SetPos(atoi(t1)+abs(downT1));
m_Progress_T2.SetPos(atoi(t2)+abs(downT2));
m_Progress_T3.SetPos(atoi(t3)+abs(downT3));
//////////////显示数据
m_edit_t1=t1;
m_edit_t2=t2;
m_edit_t3=t3;
UpdateData(false);
}
else
{
if(bauto==true)
{
nMessageStep=70;
///////////////////////////////////
}
if(bCalVal==true)
{
// AfxMessageBox("这是测量CALIBATION!");
m_TypeSelectCtrl.GetWindowText(m_TypeSelect);
m_myCALT1=ft1;
m_myCALT2=ft2;
m_myCALT3=ft3;
// m_myCALROTATION=alpha;
m_myCALROTATION=ft3;
UpdateData(false);
//////////////////////////
// if(m_myCALT1>upT1||m_myCALT2>upT2||m_myCALT3>upT3||m_myCALT1<downT1||m_myCALT2<downT2||m_myCALT3>downT3)
// {
// AfxMessageBox("这是测量CALIBATION! One of more values exced Range !Please do sensor Test again!");
// }
// else
// {
bCalVal=false;
// }
}//第一次校验值结束
else
{
// AfxMessageBox("这是测量VERIFICATION!");
m_myVERT1=ft1;
m_myVERT2=ft2;
m_myVERT3=ft3;
m_TypeSelectCtrl.GetWindowText(m_TypeSelect);
// m_myVERROTATION=alpha;
m_myVERROTATION=ft3;
//进度条显示
// m_Progress_T1.SetPos(atoi(t1)+1300);
// m_Progress_T2.SetPos(atoi(t2)+1300);
// m_Progress_T3.SetPos(atoi(t3)+1300);
UpdateData(false);
////////////////////////
// if((abs(m_myVERT1)>upT1||abs(m_myVERT2)>upT2||abs(m_myVERT3)>upT3)||(abs(m_myVERT1)<downT1||abs(m_myVERT2)<downT2||abs(m_myVERT3)>downT3))
// {
// AfxMessageBox("这是测量VERIFICATION! One of more values exced Range !Please do sensor Test again!");
// }
// else
// {
bCalVal=true;
////////////////
float cv1,cv2,cv3;
cv1=abs(m_myCALT1-m_myVERT1);
cv2=abs(m_myCALT2-m_myVERT2);
cv3=abs(m_myCALT3-m_myVERT3);
// if(abs(cv1)>0.050||abs(cv1)>0.050||abs(cv1)>0.050)
// {
// AfxMessageBox("You have to investigate the reason.\n Before calibration you have to verify.\n Calibration and verification values differ more than 50 um.");
// }
// }
}//第二次校验值结束
}
}
}
void CCheckDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
UINT nStep=nIDEvent;
if(nStep==1);
{
bool bValve21=true;
bool bValve20=true;
bool bValve31=true;
bool bValve30=true;
bool bSenso1=true;
bool bSenso2=true;
bool bSenso3=true;
m_DAQDICtrl.OpenDevice();
m_DAQDOCtrl.OpenDevice();
switch (nMessageStep)
{//switch
case 10:
m_DAQDOCtrl.SetBit(2);
m_DAQDOCtrl.BitOutput(true);//2气缸动作
SetTimer(20,3000,NULL);
nMessageStep=20;
break;
case 20:
m_DAQDICtrl.SetBit(1);
bValve21=m_DAQDICtrl.BitInput();//2气缸进位
m_DAQDICtrl.SetBit(2);
bValve20=m_DAQDICtrl.BitInput();//2气缸原位
if(bValve21&&(!bValve20))
{
KillTimer(20);
m_DAQDOCtrl.SetBit(1);
m_DAQDOCtrl.BitOutput(true);//1气缸动作
nMessageStep=30;
}
break;
case 30:
m_DAQDOCtrl.SetBit(0);
m_DAQDOCtrl.BitOutput(true);//吸真空动作
SetTimer(40,9000,NULL);
nMessageStep=40;
break;
case 40:
m_DAQDICtrl.SetBit(5);
bSenso1=m_DAQDICtrl.BitInput();
m_DAQDICtrl.SetBit(6);
bSenso2=m_DAQDICtrl.BitInput();
m_DAQDICtrl.SetBit(7);
bSenso3=m_DAQDICtrl.BitInput();
if(bSenso1&&bSenso2&&bSenso3)
{
KillTimer(40);
m_DAQDOCtrl.SetBit(3);
m_DAQDOCtrl.BitOutput(true);//3气缸动作
SetTimer(50,3000,NULL);
nMessageStep=50;
}
break;
case 50:
m_DAQDICtrl.SetBit(3);
bValve31=m_DAQDICtrl.BitInput();//3气缸进位
m_DAQDICtrl.SetBit(4);
bValve30=m_DAQDICtrl.BitInput();//3气缸原位
if(bValve31&&(!bValve30))
{
KillTimer(50);
m_DAQDOCtrl.SetBit(0);
m_DAQDOCtrl.BitOutput(false);//放真空动作
SetTimer(55,3000,NULL);
nMessageStep=55;
}
case 55:
m_DAQDICtrl.SetBit(5);
bSenso1=m_DAQDICtrl.BitInput();
m_DAQDICtrl.SetBit(6);
bSenso2=m_DAQDICtrl.BitInput();
m_DAQDICtrl.SetBit(7);
bSenso3=m_DAQDICtrl.BitInput();
if(!(bSenso1||bSenso2||bSenso3))
{
KillTimer(55);
BYTE TxData[]={0x02,0x4c,0x50,0x53,0x30,0x30,0x37,0x30,0x30,0x30,0x30,0x32,0x30,0x31,0x03};
CByteArray array;
array.RemoveAll();
array.SetSize(15);
for(int i=0;i<15;i++)
{
array.SetAt(i,TxData[i]);
}
m_Com.SetOutput(COleVariant(array));
nMessageStep=56;
Sleep(100);
}
break;
case 70:
m_DAQDOCtrl.SetBit(0);
m_DAQDOCtrl.BitOutput(true);//吸真空动作
SetTimer(80,9000,NULL);
nMessageStep=80;
break;
case 80:
m_DAQDICtrl.SetBit(5);
bSenso1=m_DAQDICtrl.BitInput();
m_DAQDICtrl.SetBit(6);
bSenso2=m_DAQDICtrl.BitInput();
m_DAQDICtrl.SetBit(7);
bSenso3=m_DAQDICtrl.BitInput();
if(bSenso1&&bSenso2&&bSenso3)
{
KillTimer(80);
m_DAQDOCtrl.SetBit(3);
m_DAQDOCtrl.BitOutput(false);//3气缸回位
SetTimer(90,3000,NULL);
nMessageStep=90;
}
break;
case 90:
m_DAQDICtrl.SetBit(3);
bValve31=m_DAQDICtrl.BitInput();//3气缸进位
m_DAQDICtrl.SetBit(4);
bValve30=m_DAQDICtrl.BitInput();//3气缸原位
if(bValve30&&(!bValve31))
{
KillTimer(90);
m_DAQDOCtrl.SetBit(0);
m_DAQDOCtrl.BitOutput(false);//放真空动作
nMessageStep=100;
}
break;
case 100:
m_DAQDICtrl.SetBit(3);
bValve31=m_DAQDICtrl.BitInput();//3气缸进位
m_DAQDICtrl.SetBit(4);
bValve30=m_DAQDICtrl.BitInput();//3气缸原位
if(bValve30&&(!bValve31))
{
m_DAQDOCtrl.SetBit(1);
m_DAQDOCtrl.BitOutput(false);//1气缸回位
nMessageStep=110;
}
break;
case 110:
m_DAQDOCtrl.SetBit(2);
m_DAQDOCtrl.BitOutput(false);//2气缸回位
SetTimer(120,3000,NULL);
nMessageStep=120;
break;
case 120:
m_DAQDICtrl.SetBit(1);
bValve21=m_DAQDICtrl.BitInput();//2气缸进位
m_DAQDICtrl.SetBit(2);
bValve20=m_DAQDICtrl.BitInput();//2气缸原位
if(bValve20&&(!bValve21))
{
KillTimer(1);
KillTimer(120);
bInMessage=true;
nMessageStep=0;
}
break;
}
m_DAQDICtrl.CloseDevice();
m_DAQDOCtrl.CloseDevice();
}
switch (nStep)
{
case 20:
KillTimer(20);
bInMessage=true;
// this->OnAutocheckend();
AfxMessageBox("气缸2未到位,请按\"停止测量\"按钮结束测量!");
break;
case 40:
KillTimer(40);
bInMessage=true;
// this->OnAutocheckend();
AfxMessageBox("真空未到位,请按\"停止测量\"按钮结束测量!");
break;
case 50:
KillTimer(50);
bInMessage=true;
// this->OnAutocheckend();
AfxMessageBox("气缸3未到位,请按\"停止测量\"按钮结束测量!");
break;
case 55:
KillTimer(55);
bInMessage=true;
// this->OnAutocheckend();
AfxMessageBox("真空未放,请按\"停止测量\"按钮结束测量!");
break;
case 80:
KillTimer(80);
bInMessage=true;
// this->OnAutocheckend();
AfxMessageBox("真空未到位,请按\"停止测量\"按钮结束测量!");
break;
case 90:
KillTimer(90);
bInMessage=true;
// this->OnAutocheckend();
AfxMessageBox("气缸3未回位,请按\"停止测量\"按钮结束测量!");
break;
case 120:
KillTimer(120);
bInMessage=true;
// this->OnAutocheckend();
AfxMessageBox("气缸2未回位,请按\"停止测量\"按钮结束测量!");
break;
}
if(nStep==200)
{
BYTE TxData[]={0x02,0x4c,0x50,0x53,0x30,0x30,0x37,0x30,0x30,0x30,0x30,0x32,0x30,0x31,0x03};
CByteArray array;
array.RemoveAll();
array.SetSize(15);
for(int i=0;i<15;i++)
{
array.SetAt(i,TxData[i]);
}
m_Com.SetOutput(COleVariant(array));
Sleep(100);
}
CDialog::OnTimer(nIDEvent);
}
void CCheckDlg::OnOnBitScanDaqdictrl1(BOOL Data)
{
// TODO: Add your control notification handler code here
m_DAQDICtrl.OpenDevice();
m_DAQDICtrl.SetBit(0);
bool bStratMessage=m_DAQDICtrl.BitInput();
if(bStratMessage==true&&bInMessage==true)
{
//////////////////////////
bInMessage=false;
nMessageStep=10;
SetTimer(1,1000,NULL);
}
m_DAQDICtrl.CloseDevice();
}
void CCheckDlg::OnAutocheckend()
{
// TODO: Add your control notification handler code here
m_AutoCheckEnd.EnableWindow(false);
m_ManCheck1.EnableWindow(true);
m_ManCheck2.EnableWindow(false);
m_ManCheck3.EnableWindow(false);
m_ManCheck4.EnableWindow(false);
m_ManCheck5.EnableWindow(false);
m_Ok.EnableWindow(true);
// m_Cancel.EnableWindow(true);
m_AutoCheck.EnableWindow(true);
///////////////////////////////////////////
bInMessage=true;
// for(int i=0;i<=9;i++)
// {
// KillTimer(i);
// }
m_DAQDICtrl.OpenDevice();
m_DAQDICtrl.SetBit(0);
m_DAQDICtrl.EnableBitScan(false);
m_DAQDICtrl.CloseDevice();
m_DAQDOCtrl.OpenDevice();
m_DAQDOCtrl.ByteOutput(0);
m_DAQDOCtrl.CloseDevice();
}
void CCheckDlg::OnOK()
{
// TODO: Add extra validation here
if(AfxMessageBox("保存数据?",MB_YESNO)==IDYES)
{
UpdateData(true);
if(n_recSTD.IsOpen())
n_recSTD.Close();
n_recSTD.Open();
n_recSTD.MoveFirst();
n_recSTD.Edit();
n_recSTD.m_Type=m_TypeSelect;
n_recSTD.m_CALT1=m_myCALT1;
n_recSTD.m_CALT2=m_myCALT2;
n_recSTD.m_CALT3=m_myCALT3;
n_recSTD.m_CALRotation=m_myCALROTATION;
n_recSTD.m_VERT1=m_myVERT1;
n_recSTD.m_VERT2=m_myVERT2;
n_recSTD.m_VERT3=m_myVERT3;
n_recSTD.m_VERRotation=m_myVERROTATION;
CTime time=CTime::GetCurrentTime();
n_recSTD.m_Time=time.Format("%y-%m-%d %H:%M");
n_recSTD.Update();
n_recSTD.Close();
if(m_Com.GetPortOpen())
m_Com.SetPortOpen(false);
CDialog::OnOK();
}
else
{
m_ManCheck1.SetFocus();
nStartMessage=0;
}
}
void CCheckDlg::OnCancel()
{
// TODO: Add extra cleanup here
m_DAQDOCtrl.OpenDevice();
m_DAQDOCtrl.ByteOutput(0);
m_DAQDOCtrl.CloseDevice();
// m_Com.SetCommPort(2);
if(m_Com.GetPortOpen())
m_Com.SetPortOpen(false);
CDialog::OnCancel();
}
HBRUSH CCheckDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(nCtlColor==CTLCOLOR_DLG)
{
pDC->SetBkColor(RGB(58,110,165));
return m_DlgbkColor;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CCheckDlg::OnStratChangepos()
{
// TODO: Add your control notification handler code here
m_CtrlStartChangPos.EnableWindow(false);
m_CtrlEndChangPos.EnableWindow(true);
m_CtrlEndChangPos.SetFocus();
m_ManCheck4.EnableWindow(false);
/////////////////////////////////
bChangePos=true;
m_DAQDOCtrl.OpenDevice();
m_DAQDOCtrl.SetBit(0);
m_DAQDOCtrl.BitOutput(0);
m_DAQDOCtrl.CloseDevice();
/////////////////////////////
for(int k=0;k<20000;k++)
{
;
for(int j=0;j<20000;j++)
{
;
}
}
nTimer=SetTimer(200,500,NULL);
ASSERT(nTimer!=0);
///////////////////////
}
void CCheckDlg::OnEndChangepos()
{
// TODO: Add your control notification handler code here
KillTimer(200);
for(int k=0;k<20000;k++)
{
;
for(int j=0;j<10000;j++)
{
;
}
}
bChangePos=false;
////////////////////////////
m_ManCheck5.EnableWindow(true);
m_ManCheck5.SetFocus();
m_CtrlEndChangPos.EnableWindow(false);
}
void CCheckDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
//画线
CPen newpen,*oldpen;
newpen.CreatePen(PS_SOLID,2,RGB(255,0,0));
oldpen=dc.SelectObject(&newpen);
//进度条上端
// dc.MoveTo(670,140);
// dc.LineTo(840,140);
//进度条下端
// dc.MoveTo(670,540);
// dc.LineTo(840,540);
// CRecsetTBound RecsetTBound;
// float upT1,downT1,upT2,downT2,upT3,downT3;
// if(RecsetTBound.IsOpen())
// {
// RecsetTBound.Close();
// }
// RecsetTBound.Open();
// upT1=1000*RecsetTBound.m_upT1;
// upT2=1000*RecsetTBound.m_upT2;
// upT3=1000*RecsetTBound.m_upT3;
// downT1=1000*RecsetTBound.m_downT1;
// downT2=1000*RecsetTBound.m_downT2;
// downT3=1000*RecsetTBound.m_downT3;
// RecsetTBound.Close();
// dc.MoveTo(670,140+400/(upT1-downT1)*upT1);
// dc.LineTo(690,140+400/(upT1-downT1)*upT1);
// dc.MoveTo(750,140+400/(upT2-downT2)*upT2);
// dc.LineTo(775,140+400/(upT2-downT2)*upT2);
// dc.MoveTo(840,140+400/(upT3-downT3)*upT3);
// dc.LineTo(860,140+400/(upT3-downT3)*upT3);
dc.MoveTo(670,140+400/2);
dc.LineTo(690,140+400/2);
dc.MoveTo(750,140+400/2);
dc.LineTo(775,140+400/2);
dc.MoveTo(840,140+400/2);
dc.LineTo(860,140+400/2);
dc.SelectObject(oldpen);
//////////////
//////
dc.SetBkColor(RGB(58,110,165));
CFont newfont,*oldfont;
CRect rect;
GetClientRect(rect);
newfont.CreateFont(
25, // nHeight
(rect.right-rect.left)/17, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
"Arial"); // lpszFacename
oldfont=(CFont *)dc.SelectObject(&newfont);
CString str="南京舜邦科技";
COLORREF oldtextcolor=dc.SetTextColor(RGB(0,255,0));
dc.TextOut((rect.right-rect.left)/6,-(rect.top-rect.bottom)/30,str);
dc.SelectObject(&oldfont);
dc.SelectObject(&oldtextcolor);
//////
//////////////
// Do not call CDialog::OnPaint() for painting messages
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -