📄 monitoraxis.cpp
字号:
// MonitorAxis.cpp : implementation file
//
#include "stdafx.h"
#include "SMT5K.h"
#include "MonitorAxis.h"
#include "SM5000.h"
#include "SerialPort.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern int CurrentAxis;
extern CString m_strTXDataCOM1;
extern CSerialPort m_ComPort;
/////////////////////////////////////////////////////////////////////////////
// CMonitorAxis property page
IMPLEMENT_DYNCREATE(CMonitorAxis, CPropertyPage)
CMonitorAxis::CMonitorAxis() : CPropertyPage(CMonitorAxis::IDD)
{
//{{AFX_DATA_INIT(CMonitorAxis)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
int i;
for(i=0;i<4;i++)
m_LPArray[i] = 0;
}
CMonitorAxis::~CMonitorAxis()
{
}
void CMonitorAxis::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMonitorAxis)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMonitorAxis, CPropertyPage)
//{{AFX_MSG_MAP(CMonitorAxis)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMonitorAxis message handlers
void CMonitorAxis::UpdateDRV(int Value)
{
m_DRV = Value;
if(m_DRV)
SetDlgItemText(IDC_STATIC_RUNSTATE,"驱动运行中");
else
SetDlgItemText(IDC_STATIC_RUNSTATE,"驱动已结束");
}
void CMonitorAxis::UpdateERR(int Value)
{
m_ERR = Value;
}
void CMonitorAxis::UpdateWhyEnd(int Value)
{
int Data = Value;
m_strWhyEnd ="";
if( Data==0 && m_DRV==0)
m_strWhyEnd ="正常结束";
else
{
if(Data & 1) m_strWhyEnd+= "IN0 ";
if(Data>>1 & 1) m_strWhyEnd+= "IN1 ";
if(Data>>2 & 1) m_strWhyEnd+= "IN2 ";
if(Data>>3 & 1) m_strWhyEnd+= "IN3 ";
if(Data>>4 & 1) m_strWhyEnd+= "LMT+ ";
if(Data>>5 & 1) m_strWhyEnd+= "LMT- ";
if(Data>>6 & 1) m_strWhyEnd+= "ALARM ";
if(Data>>7 & 1) m_strWhyEnd+= "EMG ";
}
SetDlgItemText(IDC_STATIC_WHYEND, m_strWhyEnd);
}
void CMonitorAxis::UpdateACC(int Value)
{
m_CMPP = GetBit(Value,0);
m_CMPM = GetBit(Value,1);
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_ACC, m_strACC);
//SetDlgItemInt(IDC_STATIC_ACC, Value, 0);
}
void CMonitorAxis::UpdateWhatErr(int Value)
{
int Data = Value;
m_strWhatErr ="";
if(m_ERR)
{
if(Data & 1) m_strWhatErr+= "SLMT+ ";
if(Data>>1 & 1) m_strWhatErr+= "SLMT- ";
if(Data>>2 & 1) m_strWhatErr+= "HLMT+ ";
if(Data>>3 & 1) m_strWhatErr+= "HLMT- ";
if(Data>>4 & 1) m_strWhatErr+= "ALARM+ ";
if(Data>>5 & 1) m_strWhatErr+= "EMG ";
}
SetDlgItemText(IDC_STATIC_ERR, m_strWhatErr);
}
void CMonitorAxis::UpdateIntSrc(int Value)
{
int Data = Value;
m_strIntSrc ="";
if(Data!=0)
{
if(Data & 1) m_strIntSrc+= "Pulse ";
if(Data>>1 & 1) m_strIntSrc+= "P>=C- ";
if(Data>>2 & 1) m_strIntSrc+= "P<C- ";
if(Data>>3 & 1) m_strIntSrc+= "P<C+ ";
if(Data>>4 & 1) m_strIntSrc+= "P>=C+ ";
if(Data>>5 & 1) m_strIntSrc+= "C-END ";
if(Data>>6 & 1) m_strIntSrc+= "C-STA ";
if(Data>>7 & 1) m_strIntSrc+= "D-END ";
}
SetDlgItemText(IDC_STATIC_INT, m_strIntSrc);
}
void CMonitorAxis::UpdateIO(int Value)
{
m_IO = Value;
SetDlgItemInt(IDC_STATIC_IN0, GetBit(m_IO, 0), 0 );
SetDlgItemInt(IDC_STATIC_IN1, GetBit(m_IO, 1), 0 );
SetDlgItemInt(IDC_STATIC_IN2, GetBit(m_IO, 2), 0 );
SetDlgItemInt(IDC_STATIC_IN3, GetBit(m_IO, 3), 0 );
SetDlgItemInt(IDC_STATIC_EXPP, GetBit(m_IO, 4), 0 );
SetDlgItemInt(IDC_STATIC_EXPM, GetBit(m_IO, 5), 0 );
SetDlgItemInt(IDC_STATIC_INPOS, GetBit(m_IO, 6), 0 );
SetDlgItemInt(IDC_STATIC_ALARM, GetBit(m_IO, 7), 0 );
}
void CMonitorAxis::UpdateOUTL(int Value)
{
m_OUTL = Value;
SetDlgItemInt(IDC_STATIC_OUT0, GetBit(m_OUTL, 0), 0 );
SetDlgItemInt(IDC_STATIC_OUT1, GetBit(m_OUTL, 1), 0 );
SetDlgItemInt(IDC_STATIC_OUT2, GetBit(m_OUTL, 2), 0 );
SetDlgItemInt(IDC_STATIC_OUT3, GetBit(m_OUTL, 3), 0 );
}
void CMonitorAxis::UpdateOUTH(int Value)
{
m_OUTH = Value>>1;
int m_OUTH_SEL = GetBit(Value,0);
SetDlgItemInt(IDC_STATIC_OUT4, m_OUTH_SEL? m_CMPP: GetBit(m_OUTH, 0), 0 );
SetDlgItemInt(IDC_STATIC_OUT5, m_OUTH_SEL? m_CMPM: GetBit(m_OUTH, 1), 0 );
SetDlgItemInt(IDC_STATIC_OUT6, m_OUTH_SEL? m_ASND: GetBit(m_OUTH, 2), 0 );
SetDlgItemInt(IDC_STATIC_OUT7, m_OUTH_SEL? m_DSND: GetBit(m_OUTH, 3), 0 );
}
int CMonitorAxis::GetLP(int Axis)
{
return m_LPArray[Axis];
}
void CMonitorAxis::UpdateLP(int Value)
{
m_LP = Value;
m_LPArray[CurrentAxis] = Value;
SetDlgItemInt(IDC_STATIC_LP, m_LP, 1);
}
void CMonitorAxis::UpdateEP(int Value)
{
m_EP = Value;
SetDlgItemInt(IDC_STATIC_EP, m_EP, 1);
}
void CMonitorAxis::UpdateCV(int Value)
{
m_CV = Value;
SetDlgItemInt(IDC_STATIC_CV, m_CV, 1);
}
void CMonitorAxis::UpdateCA(int Value)
{
m_CA = Value;
SetDlgItemInt(IDC_STATIC_CA, m_CA, 1);
}
BOOL CMonitorAxis::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CMonitorAxis::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
//dc.MoveTo(50,50);
//dc.LineTo(150,150);
// Do not call CPropertyPage::OnPaint() for painting messages
}
void CMonitorAxis::SpeedDownStop()
{
sd_stop(CurrentAxis);
}
void CMonitorAxis::EmergencyStop()
{
emg_stop(CurrentAxis);
}
void CMonitorAxis::GoHome()
{
go_home(CurrentAxis);
AfxMessageBox("该功能暂未实现");
}
//DEL void CMonitorAxis::OnButton1()
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL m_strTXDataCOM1.Empty();
//DEL m_strTXDataCOM1 = "@@@@@";
//DEL m_ComPort.WriteToPort((LPCTSTR)m_strTXDataCOM1);
//DEL }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -