修复Metus Jog运动错误
This commit is contained in:
@@ -428,6 +428,7 @@ HSI_STATUS HSI_Motion::Startup(HWND _hWnd, bool _bOfflineOnly)
|
||||
{
|
||||
//直线电机平台,采用串口通信,8个数据位,1个停止位,无奇偶校验,波特率256000
|
||||
m_SO7_Serial.SetPort(m_EF3COMPort, 256000, 0, 8, 1, 0); //打开串口
|
||||
#ifndef OFFLINE
|
||||
if (!m_SO7_Serial.Open()) //如果串口打开失败
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[Startup] m_SO7_Serial.Open is false,connected failed\n");
|
||||
@@ -439,6 +440,9 @@ HSI_STATUS HSI_Motion::Startup(HWND _hWnd, bool _bOfflineOnly)
|
||||
EventCallback(sEvenProp);
|
||||
return HSI_STATUS_FAILED;
|
||||
}
|
||||
#endif // OFFLINE
|
||||
|
||||
|
||||
m_SO7_Serial.SetTimeouts(1000, 1000);
|
||||
m_bConnected = true;
|
||||
g_pLogger->SendAndFlushWithTime(L"[Startup] Serial: [COM%d] is open success\n", m_EF3COMPort);
|
||||
@@ -458,7 +462,10 @@ HSI_STATUS HSI_Motion::Startup(HWND _hWnd, bool _bOfflineOnly)
|
||||
g_pLogger->SendAndFlushWithTime(L"[ACS Motion] In\n");
|
||||
g_pLogger->SendAndFlushWithTime(
|
||||
L"[ACS Motion] Wait for opening of communication with the controller... \n");
|
||||
|
||||
|
||||
#ifdef OFFLINE //如果定义离线模式
|
||||
handleACS = acsc_OpenCommSimulator();
|
||||
#else
|
||||
// 10.0.0.100 - default IP address of the controller
|
||||
handleACS = acsc_OpenCommEthernet("10.0.0.100", ACSC_SOCKET_DGRAM_PORT);
|
||||
// for the connection to the controller via local network or Internet
|
||||
@@ -477,7 +484,7 @@ HSI_STATUS HSI_Motion::Startup(HWND _hWnd, bool _bOfflineOnly)
|
||||
EventCallback(sEvenProp);
|
||||
return HSI_STATUS_FAILED;
|
||||
}
|
||||
|
||||
#endif
|
||||
//使能电机
|
||||
int Axes[] = { ACSC_AXIS_0, ACSC_AXIS_1, ACSC_AXIS_4, -1 };
|
||||
if(!acsc_EnableM(handleACS, Axes,NULL))
|
||||
@@ -1000,7 +1007,7 @@ HSI_STATUS HSI_Motion::HomeMachineOld(bool bHomed)
|
||||
{
|
||||
if (CurrentHomeMachineState == E_EF3_HOME_FINISHED)
|
||||
{
|
||||
byte AxisNumber = static_cast<byte>(AxisConvertIndex(AxisTypes));
|
||||
byte AxisNumber = static_cast<byte>(AxisConvertIndex(AxisTypes)); //HomeMachineOld
|
||||
m_cSendData[0] = CT_MOTOR;
|
||||
m_cSendData[1] = CT_MOTOR_SET;
|
||||
m_cSendData[2] = AxisTypes;
|
||||
@@ -1563,7 +1570,7 @@ HSI_STATUS HSI_Motion::JogOld(UINT AxisTypes, double Speed)
|
||||
int DecCurve(1);
|
||||
int JogSpeed(1);
|
||||
bool bJOGDir = Speed > 0 ? true : false;
|
||||
byte AxisNumber = static_cast<byte>(AxisConvertIndex(AxisTypes));
|
||||
byte AxisNumber = static_cast<byte>(AxisConvertIndex(AxisTypes));//JogOld
|
||||
jogAxisNum = AxisNumber;
|
||||
jogDirFlag = bJOGDir;
|
||||
m_Thread_State = HSI_THREAD_PAUSED;
|
||||
@@ -1836,6 +1843,7 @@ HSI_STATUS HSI_Motion::JogOld(UINT AxisTypes, double Speed)
|
||||
HSI_STATUS HSI_Motion::Jog(UINT AxisTypes, double Speed)
|
||||
{
|
||||
auto rStatus = HSI_STATUS_NORMAL;
|
||||
g_pLogger->SendAndFlushWithTime(L"[Jog] aixs: [%d] speed:[%d]\n", AxisTypes, Speed);
|
||||
if (g_pHSI_Motion)
|
||||
{
|
||||
if (m_DeviceType != 3) //非转盘设备
|
||||
@@ -1845,7 +1853,7 @@ HSI_STATUS HSI_Motion::Jog(UINT AxisTypes, double Speed)
|
||||
}
|
||||
|
||||
bool bJOGDir = Speed > 0 ? true : false; //运动方向
|
||||
byte AxisNumber = static_cast<byte>(AxisConvertIndex(AxisTypes));
|
||||
byte AxisNumber = static_cast<byte>(AxisConvertIndex(AxisTypes));//Jog
|
||||
jogAxisNum = AxisNumber;
|
||||
jogDirFlag = bJOGDir;
|
||||
m_Thread_State = HSI_THREAD_PAUSED;
|
||||
@@ -1860,10 +1868,10 @@ HSI_STATUS HSI_Motion::Jog(UINT AxisTypes, double Speed)
|
||||
}
|
||||
|
||||
//是否回过家
|
||||
if (m_Home_Machine_Axis[AxisNumber] == 0)
|
||||
{
|
||||
return rStatus;
|
||||
}
|
||||
//if (m_Home_Machine_Axis[AxisNumber] == 0)
|
||||
//{
|
||||
// return rStatus;
|
||||
//}
|
||||
|
||||
// 是否启用急停
|
||||
//if ((StartSpeed < 250) && (DriveSpeed < 6))
|
||||
@@ -1880,14 +1888,15 @@ HSI_STATUS HSI_Motion::Jog(UINT AxisTypes, double Speed)
|
||||
|
||||
//开始JOG运动
|
||||
int acsDirection = bJOGDir ? ACSC_POSITIVE_DIRECTION : ACSC_NEGATIVE_DIRECTION; //正方向,或 负方向
|
||||
if (!acsc_Jog(handleACS, 0, AxisTypes, acsDirection, nullptr))
|
||||
if (!acsc_Jog(handleACS, 0, jogAxisNum, acsDirection, nullptr))
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[Jog] [%d] Öá [%s] ·½ÏòÒÆ¶¯Ê§°Ü", AxisTypes, bJOGDir ? "Õý" : "¸º");
|
||||
printf("[Jog] 轴[%d] [%s] 方向移动失败", AxisTypes, bJOGDir? "正" : "负");
|
||||
g_pLogger->SendAndFlushWithTime(L"[Jog] aixs:[%d] JOGDir:[%s] Jog move failed\n", AxisTypes, bJOGDir ? "P" : "N");
|
||||
ErrorsHandler();
|
||||
}
|
||||
|
||||
jogMoving = true;
|
||||
g_pLogger->SendAndFlushWithTime(L"[Jog] Out, bJOGDir = %s\n", bJOGDir ? "positive":"negative");
|
||||
g_pLogger->SendAndFlushWithTime(L"[Jog] Out, bJOGDir = %s\n", bJOGDir? "positive":"negative");
|
||||
}
|
||||
return rStatus;
|
||||
}
|
||||
@@ -1912,7 +1921,7 @@ HSI_STATUS HSI_Motion::JoyStick(UINT AxisTypes, long Speed)
|
||||
int DecCurve(1);
|
||||
int JogSpeed(1);
|
||||
bool bJOGDir = Speed > 0 ? true : false;
|
||||
byte AxisNumber = static_cast<byte>(AxisConvertIndex(AxisTypes));
|
||||
byte AxisNumber = static_cast<byte>(AxisConvertIndex(AxisTypes));//JoyStick
|
||||
jogAxisNum = AxisNumber;
|
||||
jogDirFlag = bJOGDir;
|
||||
m_Thread_State = HSI_THREAD_PAUSED;
|
||||
@@ -2246,7 +2255,7 @@ HSI_STATUS HSI_Motion::StopJog()
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[StopJog] In\n");
|
||||
t_end = GetTickCount();
|
||||
g_pLogger->SendAndFlushWithTime(L"[StopJog] t_start = %d, t_end = %d\n", t_start, t_end);
|
||||
//g_pLogger->SendAndFlushWithTime(L"[StopJog] t_start = %d, t_end = %d\n", t_start, t_end);
|
||||
jogMoving = false;
|
||||
if (t_end - t_start < 100)
|
||||
{
|
||||
@@ -2297,6 +2306,7 @@ HSI_STATUS HSI_Motion::StopJog()
|
||||
return rStatus;
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
HSI_STATUS HSI_Motion::StopJogEx(UINT AxisTypes)
|
||||
{
|
||||
@@ -6883,19 +6893,19 @@ short HSI_Motion::AxisConvertIndex(UINT AxisTypes)
|
||||
}
|
||||
case HSI_MOTION_AXIS_Y:
|
||||
{
|
||||
AxisNumber = 0x02;
|
||||
AxisNumber = 0x00;
|
||||
break;
|
||||
}
|
||||
case HSI_MOTION_AXIS_Z:
|
||||
{
|
||||
AxisNumber = 0x03;
|
||||
break;
|
||||
}
|
||||
case HSI_MOTION_AXIS_R:
|
||||
{
|
||||
AxisNumber = 0x04;
|
||||
break;
|
||||
}
|
||||
//case HSI_MOTION_AXIS_R:
|
||||
// {
|
||||
// AxisNumber = 0x04;
|
||||
// break;
|
||||
// }
|
||||
default:
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"AxisConvertIndex failed,AxisTypes = %d,AxisNumber = %d\n", AxisTypes,
|
||||
|
||||
Reference in New Issue
Block a user