📄 monitoripl.cpp
字号:
// MonitorIPL.cpp : implementation file
//
#include "stdafx.h"
#include "SMT5K.h"
#include "SM5000.h"
#include "MonitorIPL.h"
#include "SMT5KDoc.h"
#include "SMT5KView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CView * pMyView ;
extern int CurrentAxis;
extern int TimerOn;
extern CDialog * pIPLFuncTestDlg;
extern int ChipSel ;
/////////////////////////////////////////////////////////////////////////////
// CMonitorIPL property page
IMPLEMENT_DYNCREATE(CMonitorIPL, CPropertyPage)
CMonitorIPL::CMonitorIPL() : CPropertyPage(CMonitorIPL::IDD)
{
//{{AFX_DATA_INIT(CMonitorIPL)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_Axis[0] = 0;
m_Axis[1] = 1;
m_Axis[2] = 2;
m_Axis[3] = 3;
m_AxisChar[0] = 'X';
m_AxisChar[1] = 'Y';
m_AxisChar[2] = 'Z';
m_AxisChar[3] = 'U';
m_AxisRunIpl = 2;
}
CMonitorIPL::~CMonitorIPL()
{
}
void CMonitorIPL::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMonitorIPL)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMonitorIPL, CPropertyPage)
//{{AFX_MSG_MAP(CMonitorIPL)
ON_WM_PAINT()
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_X_RANGE, OnDeltaposSpinXRange)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_Y_RANGE, OnDeltaposSpinYRange)
ON_CBN_CLOSEUP(IDC_COMBO_X_SEL, OnCloseupComboXSel)
ON_CBN_CLOSEUP(IDC_COMBO_Y_SEL, OnCloseupComboYSel)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_XY_SCALE, OnDeltaposSpinXyScale)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_CLR_DATA, OnClrData)
ON_BN_CLICKED(IDC_BUTTON_ORIGIN, OnButtonOrigin)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMonitorIPL message handlers
void CMonitorIPL::UpdateIDRV(int Value)
{
m_IDRV = Value;
if(m_IDRV)
SetDlgItemText(IDC_STATIC_IDRV,"插补运行中");
else
SetDlgItemText(IDC_STATIC_IDRV,"插补已结束");
}
void CMonitorIPL::UpdateCiplSegNo(int Value)
{
m_CIPL_SEGNO = Value;
SetDlgItemInt(IDC_STATIC_CIPL_SEGNO,m_CIPL_SEGNO, 0 );
}
void CMonitorIPL::UpdateCNEXT(int Value)
{
m_CNEXT = Value;
if(m_CNEXT)
{
SetDlgItemText(IDC_STATIC_CNEXT,"可写下一段");
if(pIPLFuncTestDlg!=NULL)
pIPLFuncTestDlg->SendMessage(WM_SM5K_CNEXT_VALID, 0, 0 );
}
else
SetDlgItemText(IDC_STATIC_CNEXT,"禁写下一段");
}
void CMonitorIPL::UpdateZONE(int Value)
{
m_ZONE = Value;
SetDlgItemInt(IDC_STATIC_ZONE,m_ZONE, 0 );
}
void CMonitorIPL::UpdateBPSC(int Value)
{
m_BPSC = Value;
SetDlgItemInt(IDC_STATIC_BPSC,m_BPSC, 0 );
}
char CMonitorIPL::AxisNoToAxisChar(int AxisNo)
{
char ch;
if (AxisNo==0) ch = 'X';
else if(AxisNo==1) ch = 'Y';
else if(AxisNo==2) ch = 'Z';
else if(AxisNo==3) ch = 'U';
else ch = '?';
return ch;
}
void CMonitorIPL::UpdateWR5(int Value)
{
if(ChipSel==2)
{
m_Axis[0] = 0;
m_Axis[1] = 1;
m_Axis[2] = 2;
m_Axis[3] = 3;
m_AxisChar[0] = 'X';
m_AxisChar[1] = 'Y';
m_AxisChar[2] = 'Z';
m_AxisChar[3] = 'U';
m_Axis4_En = 0;
}
else
{
m_Axis[0] = GetBit(Value,0,2);
m_Axis[1] = GetBit(Value,2,2);
m_Axis[2] = GetBit(Value,4,2);
m_Axis[3] = GetBit(Value,6,2);
m_AxisChar[0] = AxisNoToAxisChar(m_Axis[0]);
m_AxisChar[1] = AxisNoToAxisChar(m_Axis[1]);
m_AxisChar[2] = AxisNoToAxisChar(m_Axis[2]);
m_AxisChar[3] = AxisNoToAxisChar(m_Axis[3]);
m_Axis4_En = GetBit(Value,13);
}
m_LSPD = GetBit(Value,8,2);
}
void CMonitorIPL::UpdateDRV(int Value)
{
m_DRV[0] = GetBit(Value,0);
m_DRV[1] = GetBit(Value,1);
m_DRV[2] = GetBit(Value,2);
m_DRV[3] = GetBit(Value,3);
CString str;
int i;
for(i=0;i<m_AxisRunIpl;i++)
{
if(m_DRV[m_Axis[i]])
str.Format("%c轴运行插补",m_AxisChar[i]);
else
str.Format("%c轴插补结束",m_AxisChar[i]);
SetDlgItemText(IDC_STATIC_AXIS1+i,(LPCTSTR)str);
}
for(i=3;i>=m_AxisRunIpl;i--)
{
str.Format("%c轴未参与插补",m_AxisChar[i]);
SetDlgItemText(IDC_STATIC_AXIS1+i,(LPCTSTR)str);
}
}
void CMonitorIPL::UpdateCV(int Value)
{
SetDlgItemInt(IDC_STATIC_CV, Value, 1);
}
void CMonitorIPL::UpdateCA(int Value)
{
SetDlgItemInt(IDC_STATIC_CA, Value, 1);
}
void CMonitorIPL::UpdateACC(int Value)
{
m_ASND = GetBit(Value,2);
m_CNST = GetBit(Value,3);
m_DSND = GetBit(Value,4);
m_AASND = GetBit(Value,5);
m_ACNST = GetBit(Value,6);
m_ADSND = GetBit(Value,7);
if (m_ASND==1 && m_AASND==1 )
m_strACC = "加速(A增加)";
else if(m_ASND==1 && m_ACNST==1 )
m_strACC = "匀加速";
else if(m_ASND==1 && m_ADSND==1 )
m_strACC = "加速(A减少)";
else if(m_ASND==1 )
m_strACC = "T形加速";
else if(m_CNST==1 )
m_strACC = "匀速";
else if(m_DSND==1 && m_AASND==1 )
m_strACC = "减速(A增加)";
else if(m_DSND==1 && m_ACNST==1 )
m_strACC = "匀减速";
else if(m_DSND==1 && m_ADSND==1 )
m_strACC = "减速(A减少)";
else if(m_DSND==1 )
m_strACC = "T形减速";
else
m_strACC = "停止";
SetDlgItemText(IDC_STATIC_ACCSTATE, m_strACC);
}
BOOL CMonitorIPL::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// TODO: Add extra initialization here
GetDlgItem(IDC_STATIC_IPL_DRAW)->GetWindowRect(&m_RectDraw);
ScreenToClient(&m_RectDraw);
m_X0 = (m_RectDraw.left + m_RectDraw.right)/2;
m_Y0 = (m_RectDraw.top + m_RectDraw.bottom)/2;
m_XMin = m_RectDraw.left +5 ;
m_XMax = m_RectDraw.right -5;
m_YMin = m_RectDraw.top +10 ;
m_YMax = m_RectDraw.bottom -5;
m_Mul = m_RectDraw.Width()/2 ;
m_Div = ((CSMT5KView *)pMyView)->GetAxisLpRange(m_Axis[0]);
ptCurrent.x = m_X0;
ptCurrent.y = m_Y0;
m_XSel = 0;
m_YSel = 1;
((CComboBox*)GetDlgItem(IDC_COMBO_X_SEL))->SetCurSel(0);
((CComboBox*)GetDlgItem(IDC_COMBO_Y_SEL))->SetCurSel(1);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CMonitorIPL::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CPen pen(PS_SOLID,1,RGB(0,0,255));
int i;
CSMT5KDoc *pDoc = (CSMT5KDoc *)pMyView->GetDocument();
// Draw CV curve
dc.SelectObject(pen);
ptCurrent.x = m_X0;
ptCurrent.y = m_Y0 ;
dc.Ellipse(m_X0-3,m_Y0-3,m_X0+3,m_Y0+3);
dc.MoveTo(ptCurrent);
for(i=0;i<(pDoc->LPCount[m_XSel])*m_Mul;i+=(pDoc->LPCount[m_XSel]))
{
ptCurrent.x = m_X0 + (pDoc->LPArray[m_XSel][i/m_Mul])*m_Mul/m_Div;
ptCurrent.y = m_Y0 - (pDoc->LPArray[m_YSel][i/m_Mul])*m_Mul/m_Div;
if(ptCurrent.y>m_YMin && ptCurrent.y<=m_YMax && ptCurrent.x>m_XMin && ptCurrent.x<m_XMax)
dc.LineTo(ptCurrent);
else
dc.MoveTo(ptCurrent);
}
// Do not call CPropertyPage::OnPaint() for painting messages
}
void CMonitorIPL::OnDeltaposSpinXRange(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
// TODO: Add your control notification handler code here
if(pNMUpDown->iDelta==1)
m_X0 -= m_Mul/10;
else if(pNMUpDown->iDelta==-1)
m_X0 += m_Mul/10;
InvalidateRect(&m_RectDraw);
UpdateWindow();
*pResult = 0;
}
void CMonitorIPL::OnDeltaposSpinYRange(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
// TODO: Add your control notification handler code here
if(pNMUpDown->iDelta==1)
m_Y0 += m_Mul/10;
else if(pNMUpDown->iDelta==-1)
m_Y0 -= m_Mul/10;
InvalidateRect(&m_RectDraw);
UpdateWindow();
*pResult = 0;
}
void CMonitorIPL::OnDeltaposSpinXyScale(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
// TODO: Add your control notification handler code here
if(pNMUpDown->iDelta==1) // up
m_Div *= 2;
else if(pNMUpDown->iDelta==-1) // down
{
m_Div /= 2;
if(m_Div==0)
m_Div = 1;
}
InvalidateRect(&m_RectDraw);
UpdateWindow();
*pResult = 0;
}
void CMonitorIPL::OnCloseupComboXSel()
{
m_XSel = ((CComboBox*)GetDlgItem(IDC_COMBO_X_SEL))->GetCurSel();
InvalidateRect(&m_RectDraw);
UpdateWindow();
}
void CMonitorIPL::OnCloseupComboYSel()
{
m_YSel = ((CComboBox*)GetDlgItem(IDC_COMBO_Y_SEL))->GetCurSel();
InvalidateRect(&m_RectDraw);
UpdateWindow();
}
void CMonitorIPL::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if( TimerOn && m_IDRV)
{
InvalidateRect(&m_RectDraw);
UpdateWindow();
}
CPropertyPage::OnTimer(nIDEvent);
}
void CMonitorIPL::OnClrData()
{
CSMT5KDoc *pDoc = (CSMT5KDoc *)pMyView->GetDocument();
pDoc->ClearData(0);
pDoc->ClearData(1);
pDoc->ClearData(2);
pDoc->ClearData(3);
InvalidateRect(&m_RectDraw);
UpdateWindow();
}
void CMonitorIPL::SpeedDownStop()
{
sd_stop(m_Axis[0]);
}
void CMonitorIPL::EmergencyStop()
{
emg_stop(m_Axis[0]);
}
void CMonitorIPL::GoHome()
{
go_home(m_Axis[0]);
go_home(m_Axis[1]);
go_home(m_Axis[2]);
go_home(m_Axis[3]);
}
void CMonitorIPL::OnButtonOrigin()
{
m_X0 = (m_RectDraw.left + m_RectDraw.right)/2;
m_Y0 = (m_RectDraw.top + m_RectDraw.bottom)/2;
InvalidateRect(&m_RectDraw);
UpdateWindow();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -