📄 messagedlg.cpp
字号:
switch (nStep)
{
case 20:
KillTimer(20);
bInMessage=true;
this->OnStop();
AfxMessageBox("夹紧气缸未到位!");
break;
case 40:
KillTimer(40);
bInMessage=true;
this->OnStop();
AfxMessageBox("真空未到位!");
break;
case 50:
KillTimer(50);
bInMessage=true;
this->OnStop();
AfxMessageBox("后侧气缸未到位!");
break;
case 55:
KillTimer(55);
bInMessage=true;
this->OnStop();
AfxMessageBox("真空未放!");
break;
case 80:
KillTimer(80);
bInMessage=true;
this->OnStop();
AfxMessageBox("真空未到位!");
break;
case 90:
KillTimer(90);
bInMessage=true;
this->OnStop();
AfxMessageBox("后侧气缸未回位!");
break;
case 120:
KillTimer(120);
bInMessage=true;
this->OnStop();
AfxMessageBox("夹紧气缸未回位!");
break;
}
CDialog::OnTimer(nIDEvent);
}
void CMessageDlg::OnCancel()
{
// TODO: Add extra cleanup here
///////////////////
bInMessage=true;
m_StartCtrl.EnableWindow(true);
m_ButtonCancel.EnableWindow(true);
for(int i=0;i<=190;i++)
{
KillTimer(i);
}
m_DAQDOCtrl.OpenDevice();
m_DAQDICtrl.EnableBitScan(false);
m_DAQDOCtrl.ByteOutput(0);
m_DAQDOCtrl.CloseDevice();
m_StopCtrl.EnableWindow(false);
if(m_Com.GetPortOpen())
m_Com.SetPortOpen(false);
///////////////////
CDialog::OnCancel();
}
void CMessageDlg::OnStart()
{
// TODO: Add your control notification handler code here
/////////////////////////////////////////////////////////////////////////
// CSelCalDlg dlg;
// if(dlg.DoModal()==IDOK)
// {
/////
// CString cmd="select * from STD where Time='";
// cmd=cmd+str+"'";
/* if(n_SelRecsetSTD.IsOpen())
{
n_SelRecsetSTD.Close();
}
n_SelRecsetSTD.Open();
fSTDT1=n_SelRecsetSTD.m_CALT1;
fSTDT2=n_SelRecsetSTD.m_CALT2;
fSTDT3=n_SelRecsetSTD.m_CALT3;
n_SelRecsetSTD.Close();
*/ /////
// fSTDT1=dlg.fCALT1;
// fSTDT2=dlg.fCALT2;
// fSTDT3=dlg.fCALT3;
// m_edit_type=dlg.m_mineType;
/////////////////////////////////////////////////////////////////////////
// m_StartCtrl.EnableWindow(false);
// m_ButtonCancel.EnableWindow(false);
// m_DAQDICtrl.OpenDevice();
// m_DAQDICtrl.SetBit(0);
// m_DAQDICtrl.EnableBitScan(true);
// m_DAQDICtrl.SetScanTime(50);
// m_DAQDICtrl.CloseDevice();
///////////////////////////////////////
///////////////////////////////////////
//打开表CL和STAT
// m_TypeSelectCtrl.GetWindowText(m_edit_type);
// CString cmd="select * from STAT where Type='";
// cmd=cmd+m_edit_type+"'";
// if(n_recSTAT.IsOpen())
// {
// n_recSTAT.Close();
// }
// n_recSTAT.Open(AFX_DB_USE_DEFAULT_TYPE,cmd);
// m_edit_count=n_recSTAT.m_Count;
// UpdateData(false);
// n_recSTAT.Close();
m_StopCtrl.EnableWindow(true);
//打开xyr上下限表
// if(RecsetXYRBound.IsOpen())
// {
// RecsetXYRBound.Close();
// }
// RecsetXYRBound.Open();
// downX=RecsetXYRBound.m_downX;
// downY=RecsetXYRBound.m_downY;
// downR=RecsetXYRBound.m_downRotation;
// upX=RecsetXYRBound.m_upX;
// upY=RecsetXYRBound.m_upY;
// upR=RecsetXYRBound.m_upRotation;
// RecsetXYRBound.Close();
// }
}
void CMessageDlg::OnStop()
{
// TODO: Add your control notification handler code here
// bInMessage=true;
// m_StartCtrl.EnableWindow(true);
// m_ButtonCancel.EnableWindow(true);
// for(int i=0;i<=9;i++)
// {
// KillTimer(i);
// }
// m_DAQDOCtrl.OpenDevice();
// m_DAQDICtrl.EnableBitScan(false);
// m_DAQDOCtrl.ByteOutput(0);
// m_DAQDOCtrl.CloseDevice();
// m_StopCtrl.EnableWindow(false);
}
void CMessageDlg::OnOnCommMscomm1()
{
// TODO: Add your control notification handler code here
ft1=ft2=ft3=ftemp=0.0;
UpdateData(false);
//////////////////////////////////////////
VARIANT vResponse;
char c;
char *str;
int nEvent;
CString t1="";
CString t2="";
CString t3="";
nEvent=m_Com.GetCommEvent();
if(nEvent==2)
{
// if(bfirst)
// {
// m_Com.SetInputLen(0);
// m_Com.GetInput();
// bfirst=false;
// return;
// }
if(bfirst)
{
m_Com.SetInputLen(1);
do
{
vResponse=m_Com.GetInput();
str=(char*)(unsigned char*)vResponse.parray->pvData;
c=str[0];
}while(c!='R');
m_Com.SetInputLen(5);
m_Com.GetInput();
m_Com.SetInputLen(1);
//////////////////读第一个传感器数据
do
{
vResponse=m_Com.GetInput();
str=(char*)(unsigned char*)vResponse.parray->pvData;
c=str[0];
if(c==' ')
break;
t1=t1+c;
}while(c!=' ');
////////////////读第二个传感器数据
do
{
vResponse=m_Com.GetInput();
str=(char*)(unsigned char*)vResponse.parray->pvData;
c=str[0];
if(c==' ')
break;
t2=t2+c;
}while(c!=' ');
//////////////////读第三个传感器数据
do
{
vResponse=m_Com.GetInput();
str=(char*)(unsigned char*)vResponse.parray->pvData;
c=str[0];
if(c==' ')
break;
t3=t3+c;
}while(c!=' ');
//////////////////读结束符
do
{
vResponse=m_Com.GetInput();
str=(char*)(unsigned char*)vResponse.parray->pvData;
c=str[0];
}while(c!=03);
}
////////////////////////发送ACK
CByteArray array;
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号探头数据有错误,请校验!");
this->OnStop();
return;
}
if(t2=="-C"||t2=="C"||t2=="-c"||t2=="c")
{
AfxMessageBox("2号探头数据有错误,请校验!");
this->OnStop();
return;
}
if(t3=="-C"||t3=="C"||t3=="-c"||t3=="c")
{
AfxMessageBox("3号探头数据有错误,请校验!");
this->OnStop();
return;
}
*/
if(n_SelRecsetSTD.IsOpen())
{
n_SelRecsetSTD.Close();
}
n_SelRecsetSTD.Open();
m_EDIT1=fSTDT1=n_SelRecsetSTD.m_CALT1;
m_EDIT2=fSTDT2=n_SelRecsetSTD.m_CALT2;
m_EDIT3=fSTDT3=n_SelRecsetSTD.m_CALT3;
n_SelRecsetSTD.Close();
UpdateData(false);
////////////////////////数据处理
ft1=(atof(t1))/1000-fSTDT1;
ft2=(atof(t2))/1000-fSTDT2;
ft3=(atof(t3))/1000-fSTDT3;
ftemp=-((ft2+ft3))/2;
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;
/////////////////////////////
CString ss1,ss2,ss3;
ss1.Format("%.3f",ft1);
ss2.Format("%.3f",-((((ft2+ft3))/2)));
ss3.Format("%.3f",alpha);
m_T1Edit=ss1;
m_T2Edit=ss2;
m_T3Edit=ss3;
if(ft1<upX && ft1>downX)
{
m_ListX.SetBkColor(RGB(58,110,165));
m_ListX.Invalidate();
}
else
{
m_ListX.SetBkColor(RGB(255,255,0));
m_ListX.Invalidate();
}
if(ft2<upY && ft2>downY)
{
m_ListY.SetBkColor(RGB(58,110,165));
m_ListY.Invalidate();
}
else
{
m_ListY.SetBkColor(RGB(255,255,0));
m_ListY.Invalidate();
}
if(alpha<upR && alpha>downR)
{
m_ListR.SetBkColor(RGB(58,110,165));
m_ListR.Invalidate();
}
else
{
m_ListR.SetBkColor(RGB(255,255,0));
m_ListR.Invalidate();
}
UpdateData(false);
/////////////////////////////下一步
/* for(int i=0;i<30000;i++)
{
;
for(int j=0;j<10000;j++)
{
;
}
}
m_DAQDICtrl.SetBit(5);
bool bSenso1=m_DAQDICtrl.BitInput();
m_DAQDICtrl.SetBit(6);
bool bSenso2=m_DAQDICtrl.BitInput();
m_DAQDICtrl.SetBit(7);
bool bSenso3=m_DAQDICtrl.BitInput();
*/
// if(!(bSenso1&&bSenso2&&bSenso3))
// {
nMessageStep=70;
// }
/* else
{
bInMessage=true;
AfxMessageBox("真空未放,请按\"停止测量\"按钮结束测量!");
return;
}*/
///////////////////////////////////
}
}
void CMessageDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
dc.SetBkColor(RGB(58,110,165));
CFont newfont,*oldfont;
CRect rect;
GetClientRect(rect);
newfont.CreateFont(
40, // 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)/20,str);
dc.SelectObject(&oldfont);
dc.SelectObject(&oldtextcolor);
// Do not call CDialog::OnPaint() for painting messages
}
void CMessageDlg::OnButtonViewdate()
{
// TODO: Add your control notification handler code here
CReport_29SF dlg;
dlg.DoModal();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -