?? downass.cpp
字號:
// DownAss.cpp : implementation file
//
#include "stdafx.h"
#include "alfa.h"
#include "DownAss.h"
#include "Main.h"
#include "mccl.h"
#include "sys.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDownAss dialog
CDownAss::CDownAss(CWnd* pParent /*=NULL*/)
: CDialog(CDownAss::IDD, pParent)
{
//{{AFX_DATA_INIT(CDownAss)
m_edt1 = 0.0;
m_edt2 = 10;
//}}AFX_DATA_INIT
}
void CDownAss::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDownAss)
DDX_Control(pDX, IDC_EDIT2, m_edit2);
DDX_Control(pDX, IDC_EDIT1, m_edit1);
DDX_Text(pDX, IDC_EDIT1, m_edt1);
DDX_Text(pDX, IDC_EDIT2, m_edt2);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDownAss, CDialog)
//{{AFX_MSG_MAP(CDownAss)
ON_WM_SHOWWINDOW()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDownAss message handlers
void CDownAss::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
CString m_Dist_str, m_Speed_str;
// TODO: Add your message handler code here
if(bShow==1) {
CMain * main=(CMain *)GetParent();
m_edt1=main->dlgfixedmode->moveparam.distance_z_ass;
m_edt2=main->dlgfixedmode->moveparam.speed_down_ass;
m_Dist_str.Format("%6.2f", m_edt1);
m_Speed_str.Format("%3d", m_edt2);
GetDlgItem(IDC_EDIT1)->SetWindowText(m_Dist_str);
GetDlgItem(IDC_EDIT2)->SetWindowText(m_Speed_str);
m_Kill_Flag=0;
// UpdateData(FALSE);
main->dlgcur =this;
}
}
void CDownAss::OnOK()
{
// TODO: Add extra validation here
CMain * main=(CMain *)GetParent();
UpdateData();
main->dlgfixedmode->moveparam.distance_z_ass=m_edt1;
main->dlgfixedmode->moveparam.speed_down_ass=m_edt2;
JogDir=0; KillTimer(48);
ShowWindow(FALSE);
main->dlgfixedmode->ShowWindow(TRUE);
}
void CDownAss::OnCancel()
{
// TODO: Add extra cleanup here
CMain * main=(CMain *)GetParent();
JogDir=0; KillTimer(48);
ShowWindow(FALSE);
main->dlgfixedmode->ShowWindow(TRUE);
}
BOOL CDownAss::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
h_SkinDialog.SubClassDialog(m_hWnd);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDownAss::OnLButtonDown(UINT nFlags, CPoint point)
{
CString m_x_str, m_z_str;
long m_curmz, m_curmy;
double m_y, m_z;
WORD wInput0;
WORD OTStatus, OTStatus1;
MCC_GetRIOInputValue(&wInput0, RIO_SET1, RIO_PORT0, CARD_INDEX);
MCC_GetENCValue(&m_curmy, 2, 0);
MCC_GetENCValue(&m_curmz, 4, 0);
m_curmy=m_curmy*unit2a;
m_curmz=m_curmz*unit4a;
m_y=(m_curmy/2500.0)*unit2;
m_z=(m_curmz/2500.0)*unit4;
if((OUTPUT0 & 0x2000)>0 || (wInput0 & 0x0080)>0) return;
if(PtInRect(CRect(214, 36, 264, 66), point)) {
MCC_GetLimitSwitchStatus(&OTStatus1, 0, 4, 0);
if(MCC_GetLimitSwitchStatus(&OTStatus, 1, 4, 0)==0) { // SZ+, HOT
if(OTStatus==1) ;
else if(OTStatus1==1) {
JogDir=9; m_Kill_Flag=-1;
KillTimer(48);
MCC_JogConti(1, JogSpeed, 2, 1);
SetTimer(48, 10, NULL);
}
else if((m_z>msafepos || (wInput0 & 0x0800)==0) &&
m_y>mytsafepos && m_y<mypsafepos) ; // SZ+, SOT
else if(m_z>SZSOT_Plus) ;
else if(m_y<mytsafepos && (wInput0 & 0x0001)==0) ;
else {
JogDir=9; m_Kill_Flag=-1;
KillTimer(48);
MCC_JogConti(1, JogSpeed, 2, 1);
SetTimer(48, 10, NULL);
}
}
}
else if(PtInRect(CRect(154, 36, 204, 66), point)) {
if(MCC_GetLimitSwitchStatus(&OTStatus, 0, 4, 0)==0) { // SZ-, HOT
if(OTStatus==1) ;
else if(m_z<SZSOT_Minus) ; // SZ-, SOT
else {
JogDir=10; m_Kill_Flag=-1;
KillTimer(48);
MCC_JogConti(-1, JogSpeed, 2, 1);
SetTimer(48, 10, NULL);
}
}
}
CDialog::OnLButtonDown(nFlags, point);
}
void CDownAss::OnLButtonUp(UINT nFlags, CPoint point)
{
CString s_z_str;
long m_cursz;
double s_z;
if(JogDir==9 || JogDir==10) {
// JogDir=0;
MCC_GetENCValue(&m_cursz, 4, 0);
m_cursz=m_cursz*unit4a;
s_z=(m_cursz/2500.0)*unit4;
s_z_str.Format("%6.2f", s_z);
GetDlgItem(IDC_EDIT1)->SetWindowText(s_z_str);
m_Kill_Flag=100;
// KillTimer(41);
}
MCC_AbortMotion(0);// stop current motion and discard all motion commands in a command queue
MCC_AbortMotion(1);// stop current motion and discard all motion commands in a command queue
MCC_AbortMotion(2);// stop current motion and discard all motion commands in a command queue
// MCC_AbortMotionEx(MX_DecTime*JogSpeed/100.0, GROUP_INDEX0);
// MCC_AbortMotionEx(SX_DecTime*JogSpeed/100.0, GROUP_INDEX1);
// MCC_AbortMotionEx(Y_DecTime*JogSpeed/100.0, GROUP_INDEX2);
CDialog ::OnLButtonUp(nFlags, point);
}
void CDownAss::OnTimer(UINT nIDEvent)
{
int TempAlarm;
CString m_z_str;
long m_curmz, m_curmy;
double m_y, m_z;
WORD wInput0;
WORD OTStatus;
TempAlarm=0;
MCC_GetRIOInputValue(&wInput0, RIO_SET1, RIO_PORT0, CARD_INDEX);
MCC_GetENCValue(&m_curmy, 2, 0);
MCC_GetENCValue(&m_curmz, 4, 0);
m_curmy=m_curmy*unit2a;
m_curmz=m_curmz*unit4a;
m_y=(m_curmy/2500.0)*unit2;
m_z=(m_curmz/2500.0)*unit4;
m_z_str.Format("%6.2f", m_z);
GetDlgItem(IDC_EDIT1)->SetWindowText(m_z_str);
if(m_Kill_Flag>0) { m_Kill_Flag--; return; }
if(m_Kill_Flag==0) { JogDir=0; m_Kill_Flag=-1; KillTimer(48); return; }
if((OUTPUT0 & 0x2000)>0 || (wInput0 & 0x0080)>0) TempAlarm=1;
if(JogDir==9) {
if(MCC_GetLimitSwitchStatus(&OTStatus, 1, 4, 0)==0) { // SZ+, HOT
if(OTStatus==1) TempAlarm=1 ;
else if((m_z>msafepos || (wInput0 & 0x0800)==0) &&
m_y>mytsafepos && m_y<mypsafepos) TempAlarm=1; // SZ+, SOT
else if(m_z>SZSOT_Plus) TempAlarm=1;
}
else TempAlarm=1;
}
else if(JogDir==10) {
if(MCC_GetLimitSwitchStatus(&OTStatus, 0, 4, 0)==0) { // SZ-, HOT
if(OTStatus==1) TempAlarm=1;
else if(m_z<SZSOT_Minus) TempAlarm=1; // SZ-, SOT
}
else TempAlarm=1;
}
if(TempAlarm>0) {
JogDir=0;
MCC_AbortMotion(0);
MCC_AbortMotion(1);
MCC_AbortMotion(2);
// MCC_AbortMotionEx(MX_DecTime*JogSpeed/100.0, GROUP_INDEX0);
// MCC_AbortMotionEx(SX_DecTime*JogSpeed/100.0, GROUP_INDEX1);
// MCC_AbortMotionEx(Y_DecTime*JogSpeed/100.0, GROUP_INDEX2);
m_Kill_Flag=100;
// KillTimer(42);
}
CDialog::OnTimer(nIDEvent);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -