📄 autofull.cpp
字号:
// AutoFull.cpp : implementation file
//
#include "stdafx.h"
#include "alfa.h"
#include "AutoFull.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
#define TimerID 11
/////////////////////////////////////////////////////////////////////////////
// CAutoFull dialog
// int msgsw2,msgsw7,msgsw8,msgsw9,msgsw10,msgsw11,msgsw12;
// int msgsw13,msgsw14,msgsw15,msgsw16;
unsigned int msgsw1, msgsw2;
CAutoFull::CAutoFull(CWnd* pParent /*=NULL*/)
: CDialog(CAutoFull::IDD, pParent)
{
//{{AFX_DATA_INIT(CAutoFull)
m_mdmx = 0.0;
m_mdmz = 0.0;
m_mdmsy = 0.0;
m_mdsx = 0.0;
m_mdsz = 0.0;
msgsw1=0;
msgsw2=0;
//}}AFX_DATA_INIT
}
void CAutoFull::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAutoFull)
DDX_Control(pDX, IDC_VAC, m_vac);
DDX_Control(pDX, IDC_SDM, m_sdm);
DDX_Control(pDX, IDC_MOP, m_mop);
DDX_Control(pDX, IDC_EMC, m_emc);
DDX_Control(pDX, IDC_EFP, m_efp);
DDX_Control(pDX, IDC_CK, m_ck);
DDX_Control(pDX, IDC_AUTO, m_auto);
// DDX_Text(pDX, IDC_EDIT1, m_mdmx);
// DDX_Text(pDX, IDC_EDIT2, m_mdmz);
// DDX_Text(pDX, IDC_EDIT3, m_mdmsy);
// DDX_Text(pDX, IDC_EDIT4, m_mdsx);
// DDX_Text(pDX, IDC_EDIT5, m_mdsz);
DDX_Text(pDX, IDC_EDIT1, m_mdmx_str);
DDX_Text(pDX, IDC_EDIT2, m_mdmz_str);
DDX_Text(pDX, IDC_EDIT3, m_mdmsy_str);
DDX_Text(pDX, IDC_EDIT4, m_mdsx_str);
DDX_Text(pDX, IDC_EDIT5, m_mdsz_str);
DDX_Text(pDX, IDC_EDIT6, m_fixstep);
DDX_Text(pDX, IDC_EDIT7, m_timecount);
DDX_Text(pDX, IDC_EDIT8, m_inputdata);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAutoFull, CDialog)
//{{AFX_MSG_MAP(CAutoFull)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_WM_SHOWWINDOW()
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAutoFull message handlers
// Timer
void CAutoFull::OnButton1()
{
// TODO: Add your control notification handler code here
ShowWindow(FALSE);
CMain * main=(CMain *)GetParent();
main->dlgautotimer->ShowWindow(TRUE);
KillTimer(TimerID);
}
// Speed
void CAutoFull::OnButton2()
{
// TODO: Add your control notification handler code here
ShowWindow(FALSE);
CMain * main=(CMain *)GetParent();
main->dlgautofixspeed->ShowWindow(TRUE);
KillTimer(TimerID);
}
//Exit
void CAutoFull::OnButton3()
{
// TODO: Add your control notification handler code here
ShowWindow(FALSE);
CMain * main=(CMain *)GetParent();
main->dlgauto->ShowWindow(TRUE);
KillTimer(TimerID);
// main->dlgmainfrm->ShowWindow(TRUE);
// main->dlgauto->KillTimer(2);
// main->dlgauto->PostMessage(WM_LISTADD);
// main->dlgmainfrm->ShowWindow(TRUE);
}
// Position
void CAutoFull::OnButton4()
{
// TODO: Add your control notification handler code here
ShowWindow(FALSE);
CMain * main=(CMain *)GetParent();
main->dlgautofixpos->ShowWindow(TRUE);
KillTimer(TimerID);
}
void CAutoFull::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
if(bShow==1)
{
CMain * main=(CMain *)GetParent();
main->dlgcur=this;
SetTimer(TimerID, 300, NULL);
}
}
void CAutoFull::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
long m_atgdmx,m_atgdmz,m_atgdmsy,m_atgdsx,m_atgdsz;
MCC_GetENCValue(&m_atgdmx, 0, 0);
MCC_GetENCValue(&m_atgdmz, 1, 0);
MCC_GetENCValue(&m_atgdmsy,2, 0);
MCC_GetENCValue(&m_atgdsx, 3, 0);
MCC_GetENCValue(&m_atgdsz, 4, 0);
m_atgdmx=m_atgdmx*unit0a;
m_atgdmz=m_atgdmz*unit1a;
m_atgdmsy=m_atgdmsy*unit2a;
m_atgdsx=m_atgdsx*unit3a;
m_atgdsz=m_atgdsz*unit4a;
m_mdmx=(m_atgdmx/2500.0)*unit0;
m_mdmz=(m_atgdmz/2500.0)*unit1;
m_mdmsy=(m_atgdmsy/2500.0)*unit2;
m_mdsx=(m_atgdsx/2500.0)*unit3;
m_mdsz=(m_atgdsz/2500.0)*unit4;
m_mdmx_str.Format("%6.2f ", m_mdmx);
m_mdmz_str.Format("%6.2f ", m_mdmz);
m_mdmsy_str.Format("%6.2f ", m_mdmsy);
m_mdsx_str.Format("%6.2f ", m_mdsx);
m_mdsz_str.Format("%6.2f ", m_mdsz);
UpdateData(FALSE);
m_fixstep=GFixStep;
m_timecount=GTimeCount;
m_inputdata=GInputData;
UpdateData(FALSE);
if(msgalm>0 || JogAlarm>0) {
if(msgalm!=msgsw2 || JogAlarm!=msgsw1) {
if((msgalm & 0x80000000)>0 || JogAlarm>0) {
// 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, GROUP_INDEX0);
MCC_AbortMotionEx(SX_DecTime, GROUP_INDEX1);
MCC_AbortMotionEx(Y_DecTime, GROUP_INDEX2);
}
else if((msgalm & 0x40000000)>0) {
MCC_HoldMotion(0);
MCC_HoldMotion(1);
MCC_HoldMotion(2);
}
msgsw1=JogAlarm;
msgsw2=msgalm;
dlgalm1->OnAtmsgAlm();
dlgalm1->ShowWindow(TRUE);
}
}
else {
msgsw2=0;
dlgalm1->OnAtmsgAlm();
dlgalm1->ShowWindow(FALSE);
}
WORD wInput0;
WORD wInput;
MCC_GetRIOInputValue( &wInput0, RIO_SET1, RIO_PORT0, CARD_INDEX);// get remote I/O set 0's DI0 ~ DI15 statuses
wInput=wInput0;
CClientDC dc(this);
if(wInput0==(wInput|0x0001))
{
ShowTransparentBitmap(&dc,IDB_BITMAP7,led[2].x,led[2].y);
}
else
ShowTransparentBitmap(&dc,IDB_BITMAP8,led[2].x,led[2].y);
wInput=wInput0;
if(wInput0==(wInput|0x0002))
{
ShowTransparentBitmap(&dc,IDB_BITMAP7,led[0].x,led[0].y);
}
else
ShowTransparentBitmap(&dc,IDB_BITMAP8,led[0].x,led[0].y);
wInput=wInput0;
if(wInput0==(wInput|0x0020))
{
ShowTransparentBitmap(&dc,IDB_BITMAP7,led[1].x,led[1].y);
}
else
ShowTransparentBitmap(&dc,IDB_BITMAP8,led[1].x,led[1].y);
wInput=wInput0;
if(wInput0==(wInput|0x0080))
{
ShowTransparentBitmap(&dc,IDB_BITMAP7,led[6].x,led[6].y);
}
else
ShowTransparentBitmap(&dc,IDB_BITMAP8,led[6].x,led[6].y);
wInput=wInput0;
if(wInput0==(wInput|0x0100))
{
ShowTransparentBitmap(&dc,IDB_BITMAP7,led[3].x,led[3].y);
}
else
ShowTransparentBitmap(&dc,IDB_BITMAP8,led[3].x,led[3].y);
WORD wOUTPUT;
wOUTPUT=OUTPUT0;
if(OUTPUT0==(wOUTPUT|0x0100))
{
ShowTransparentBitmap(&dc,IDB_BITMAP7,led[5].x,led[5].y);
}
else
{
ShowTransparentBitmap(&dc,IDB_BITMAP8,led[5].x,led[5].y);
}
wOUTPUT=OUTPUT0;
if(OUTPUT0==(wOUTPUT|0x0200))
{
ShowTransparentBitmap(&dc,IDB_BITMAP7,led[4].x,led[4].y);
}
else
{
ShowTransparentBitmap(&dc,IDB_BITMAP8,led[4].x,led[4].y);
}
CDialog::OnTimer(nIDEvent);
}
BOOL CAutoFull::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
h_SkinDialog.SubClassDialog(m_hWnd);
dlgalm1=new Calm1;
dlgalm1->Create(IDD_DIALOGALM1, this);
dlgalm1->MoveWindow(0, 410, 550, 120);
// dlgalm1->ShowWindow(TRUE);
CRect rt;
m_vac.GetWindowRect(rt);
led[0].x=rt.left;
led[0].y=rt.top;
m_ck.GetWindowRect(rt);
led[1].x=rt.left;
led[1].y=rt.top;
m_mop.GetWindowRect(rt);
led[2].x=rt.left;
led[2].y=rt.top;
m_sdm.GetWindowRect(rt);
led[3].x=rt.left;
led[3].y=rt.top;
m_efp.GetWindowRect(rt);
led[4].x=rt.left;
led[4].y=rt.top;
m_emc.GetWindowRect(rt);
led[5].x=rt.left;
led[5].y=rt.top;
m_auto.GetWindowRect(rt);
led[6].x=rt.left;
led[6].y=rt.top;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
// Reset
void CAutoFull::OnButton5()
{
// TODO: Add your control notification handler code here
// 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, GROUP_INDEX0);
MCC_AbortMotionEx(SX_DecTime, GROUP_INDEX1);
MCC_AbortMotionEx(Y_DecTime, GROUP_INDEX2);
autoovflg=0;
CMain * main=(CMain *)GetParent();
main->dlgauto->KillTimer(2);
msgalm=0;
// LatchedAlm=0;
JogAlarm=0;
// autorunflg=0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -