正在调试 档位速度
This commit is contained in:
@@ -63,17 +63,6 @@ HANDLE HSI_Motion::m_ThreadTCP_Id = nullptr;
|
||||
int HSI_Motion::m_ThreadTCP_State = TCPIP_THREAD_PAUSED;
|
||||
SOCKET m_socket[4] = {0};
|
||||
|
||||
//===========================================================================
|
||||
//运动类构造函数,涉及 运动控制参数、插补、回家、摇杆、日志等配置信息的加载
|
||||
|
||||
|
||||
void ErrorsHandler(const char* ErrorMessage, BOOL fCloseComm)
|
||||
{
|
||||
printf(ErrorMessage);
|
||||
printf("press any key to exit.\n");
|
||||
if (fCloseComm) acsc_CloseComm(handleACS);
|
||||
_getch();
|
||||
};
|
||||
|
||||
void ErrorsHandler()
|
||||
{
|
||||
@@ -100,8 +89,8 @@ void ErrorsHandler()
|
||||
g_pLogger->SendAndFlushWithTime(L"[ACS Motion] ACS Communication handle is invalid\n");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//运动类构造函数,涉及 运动控制参数、插补、回家、摇杆、日志等配置信息的加载
|
||||
HSI_Motion::HSI_Motion()
|
||||
{
|
||||
TRACE0("HSI_Motion Constructor!\n");
|
||||
@@ -242,8 +231,8 @@ HSI_Motion::HSI_Motion()
|
||||
{
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
m_JogDriveSpeed[j][i] = 10; //表示5个档位 轴号,从1开始;5:档位
|
||||
m_JogStartSpeed[j][i] = 10;
|
||||
m_JogDriveSpeed[j][i] = 20; //表示5个档位 轴号,从1开始;5:档位
|
||||
m_JogStartSpeed[j][i] = 20;
|
||||
m_JogAccLine[j][i] = 5;
|
||||
m_JogAccCurve[j][i] = 0;
|
||||
m_JogDecLine[j][i] = 5;
|
||||
@@ -252,6 +241,7 @@ HSI_Motion::HSI_Motion()
|
||||
m_Home_Machine_Axis[i] = 1; //用于启动时需要回原点的轴号选择,赋值1表示该轴需要回家
|
||||
m_Home_Pos_Axis[i] = 0; //记住关闭电源时的位置,用于判断是否还需要回原点
|
||||
}
|
||||
|
||||
m_Home_Machine_Axis[4] = 0; //用于启动时需要回原点的轴号选择
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
@@ -1047,6 +1037,7 @@ HSI_STATUS HSI_Motion::HomeMachineOld(bool bHomed)
|
||||
HSI_STATUS HSI_Motion::HomeMachine(bool bHomed)
|
||||
{
|
||||
auto rStatus = HSI_STATUS_NORMAL;
|
||||
g_pLogger->SendAndFlushWithTime(L"[HomeMachine] In\n");
|
||||
if (!bHomed)
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[HomeMachine] bHomed No Need Reture\n");
|
||||
@@ -1056,9 +1047,9 @@ HSI_STATUS HSI_Motion::HomeMachine(bool bHomed)
|
||||
{
|
||||
return HSI_STATUS_NORMAL;
|
||||
}
|
||||
if (g_pHSI_Motion)
|
||||
if (g_pHSI_Motion &&(handleACS != ACSC_INVALID))
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[HomeMachine] In\n");
|
||||
|
||||
//判断是否需要回家
|
||||
bool home(false);
|
||||
IsHomed(home);
|
||||
@@ -1095,15 +1086,32 @@ HSI_STATUS HSI_Motion::HomeMachine(bool bHomed)
|
||||
return HSI_STATUS_FAILED;
|
||||
}
|
||||
|
||||
//再次读取回家标志位,或者上个动作完成回调
|
||||
IsHomed(home);
|
||||
if (home == true)
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[HomeMachine] Go Home success\n");
|
||||
}
|
||||
//等待运动结束 ,方式1
|
||||
/* acsc_WaitMotionEnd(handleACS, ACSC_AXIS_1, INFINITE);
|
||||
g_pLogger->SendAndFlushWithTime(L"[HomeMachine] X homed\n");
|
||||
|
||||
acsc_WaitMotionEnd(handleACS, ACSC_AXIS_0, INFINITE);
|
||||
g_pLogger->SendAndFlushWithTime(L"[HomeMachine] Y homed\n");
|
||||
|
||||
acsc_WaitMotionEnd(handleACS, ACSC_AXIS_4, INFINITE);
|
||||
g_pLogger->SendAndFlushWithTime(L"[HomeMachine] Z homed\n");*/
|
||||
|
||||
//等待运动结束 ,方式2
|
||||
do
|
||||
{
|
||||
//再次读取回家标志位,或者上个动作完成回调
|
||||
IsHomed(home);
|
||||
Sleep(200);
|
||||
|
||||
} while (!home);
|
||||
|
||||
g_pLogger->SendAndFlushWithTime(L"[HomeMachine] Go Home success\n");
|
||||
g_pLogger->SendAndFlushWithTime(L"[HomeMachine] Out\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[HomeMachine] faild, g_pHSI_Motion or handleACS not invaild! \n");
|
||||
}
|
||||
return rStatus;
|
||||
}
|
||||
|
||||
@@ -1473,12 +1481,12 @@ HSI_STATUS HSI_Motion::IsHomed(bool& bHomed)
|
||||
rStatus = HSI_STATUS_FAILED;
|
||||
bHomed = false;
|
||||
}
|
||||
|
||||
g_pLogger->SendAndFlushWithTime(L"[IsHomed] ACS Read YAW_HOME_DONE X:[%d] Y1:[%d] Y2:[%d] Z:[%d]\n", isHomed[0],
|
||||
isHomed[1], isHomed[2], isHomed[3]);
|
||||
|
||||
g_pLogger->SendAndFlushWithTime(L"[IsHomed] ACS Read YAW_HOME_DONE X:[%d] Y:[%d] Z:[%d]\n", isHomed[0],
|
||||
isHomed[1], isHomed[2]);
|
||||
|
||||
//如果各个轴标志位 已经回过家
|
||||
if (isHomed[0] == 1 && isHomed[1] == 1 && isHomed[2] == 1 && isHomed[3] == 1)
|
||||
if (isHomed[0] == 2 && isHomed[1] == 1 && isHomed[2] == 1 && isHomed[3] == 1)
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[IsHomed] E_GTS_HOME_FINISHED\n");
|
||||
CurrentHomeMachineState = E_EF3_HOME_FINISHED;
|
||||
@@ -1846,7 +1854,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] SpeedGear: [%lf]\n", AxisTypes, Speed);
|
||||
g_pLogger->SendAndFlushWithTime(L"[Jog] Aixs: [%d] SpeedGear: [%lf]\n", AxisTypes, Speed);
|
||||
if (g_pHSI_Motion)
|
||||
{
|
||||
if (m_DeviceType != 3) //非转盘设备
|
||||
@@ -1899,7 +1907,7 @@ HSI_STATUS HSI_Motion::Jog(UINT AxisTypes, double Speed)
|
||||
|
||||
JogSpeed = abs(SpeedPercent(AxisNumber, Speed, DriveSpeed, StartSpeed, AccLine, DecLine, AccCurve, DecCurve));
|
||||
|
||||
g_pLogger->SendAndFlushWithTime(L"[Jog] StartSpeed: [%d], DriveSpeed: [%d], AccCurve: [%d], AccLine: [%d], DecCurve: [%d], DecLine: [%d]\n", StartSpeed, DriveSpeed, AccCurve, AccLine, DecCurve, DecLine);
|
||||
g_pLogger->SendAndFlushWithTime(L"[Jog] Speed: [%d], DriveSpeed: [%d], AccCurve: [%d], AccLine: [%d], DecCurve: [%d], DecLine: [%d]\n", Speed, DriveSpeed, AccCurve, AccLine, DecCurve, DecLine);
|
||||
|
||||
if (m_DeviceType != 3)
|
||||
{
|
||||
@@ -2518,6 +2526,14 @@ int HSI_Motion::P2P(short AxisNumber, long Pos, double Speed, double Acc)
|
||||
//===========================================================================
|
||||
//运动控制部分
|
||||
//===========================================================================
|
||||
/**
|
||||
* \brief 对比现在编码器位置和期望位置, position给上层用的, HSI内部用的是EncPrf
|
||||
* \param AxisTypes
|
||||
* \param EncPos
|
||||
* \param PrfPos
|
||||
* \param Count
|
||||
* \return
|
||||
*/
|
||||
HSI_STATUS HSI_Motion::GetPositionEncPrfMultiOld(UINT AxisTypes, double* EncPos, double* PrfPos, int Count)
|
||||
{
|
||||
auto rStatus = HSI_STATUS_NORMAL;
|
||||
@@ -3530,6 +3546,7 @@ HSI_STATUS HSI_Motion::SetPositionXyz(UINT AxisTypes, double PositionX, double P
|
||||
m_Thread_State = HSI_THREAD_RUNNING;
|
||||
SetEvent(m_hTriggerEvent);
|
||||
}
|
||||
|
||||
if (eType == HSI_MOTION_MOVE_WAIT) //等待模式
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[SetPositionXyz] Out Success Wait Mode\n");
|
||||
@@ -3905,13 +3922,15 @@ HSI_STATUS HSI_Motion::Load_EF3_Motion_Inifile(CString GoogolIniFile)
|
||||
GetPrivateProfileString(L"JOG_SPEED", L"JOG_DRIVESPEED_" + strGear[i] + axisNum[j], L"10",
|
||||
temp.GetBufferSetLength(50), 10, csAppPath);
|
||||
float speed = (atof(T2A(temp)));
|
||||
//m_JogDriveSpeed[j][i] = GetPrivateProfileInt(L"JOG_SPEED", L"JOG_DRIVESPEED_" , 10, csAppPath);
|
||||
m_JogDriveSpeed[j][i] = speed / (m_Resolution[j] * 50);
|
||||
m_JogDriveSpeed[j][i] = GetPrivateProfileInt(L"JOG_SPEED", L"JOG_DRIVESPEED_" , 10, csAppPath);
|
||||
//m_JogDriveSpeed[j][i] = speed / (m_Resolution[j] * 50);
|
||||
g_pLogger->SendAndFlushWithTime(L"[Load_EF3_Motion_Inifile] m_JogDriveSpeed[%d][%d]: %lf %d\n", j, i, speed,m_JogDriveSpeed[j][i]);//打印配置文件 档位速度
|
||||
|
||||
GetPrivateProfileString(L"JOG_SPEED", L"JOG_STARTSPEED_" + strGear[i] + axisNum[j], L"10",
|
||||
temp.GetBufferSetLength(50), 10, csAppPath);
|
||||
speed = (atof(T2A(temp)));
|
||||
//m_JogStartSpeed[j][i] = GetPrivateProfileInt(L"JOG_SPEED", L"JOG_STARTSPEED_" + strGear[i] + axisNum[j], 10, csAppPath);
|
||||
m_JogStartSpeed[j][i] = speed / (m_Resolution[j] * 50);
|
||||
m_JogStartSpeed[j][i] = GetPrivateProfileInt(L"JOG_SPEED", L"JOG_STARTSPEED_" + strGear[i] + axisNum[j], 10, csAppPath);
|
||||
//m_JogStartSpeed[j][i] = speed / (m_Resolution[j] * 50);
|
||||
m_JogAccLine[j][i] = GetPrivateProfileInt(L"JOG_SPEED", L"JOG_LINE_" + strGear[i] + axisNum[j], 10,
|
||||
csAppPath);
|
||||
m_JogDecLine[j][i] = GetPrivateProfileInt(L"JOG_SPEED", L"JOG_LINE_" + strGear[i] + axisNum[j], 10,
|
||||
@@ -6828,7 +6847,7 @@ HSI_STATUS HSI_Motion::GetPntsDistance(double& pDistance, int& spTimeCount)
|
||||
|
||||
//===========================================================================
|
||||
/**
|
||||
* \brief 运动控制参数读取及设置
|
||||
* \brief 界面挡位获取速度
|
||||
* \param AxisNum
|
||||
* \param Speed
|
||||
* \param DirveSpeed
|
||||
@@ -6856,6 +6875,7 @@ int HSI_Motion::SpeedPercent(int AxisNum, double& Speed, int& DirveSpeed, int& S
|
||||
DecLine = m_JogDecLine[AxisNum][0];
|
||||
AccCurve = m_JogAccCurve[AxisNum][0];
|
||||
DecCurve = m_JogDecCurve[AxisNum][0];
|
||||
g_pLogger->SendAndFlushWithTime(L"[SpeedPercent] 0.81 DriveSpeed: [%d], StartSpeed: [%d], AccLine: [%d], DecLine: [%d], AccCurve: [%d], DecCurve: [%d]\n", DirveSpeed, StartSpeed, AccLine, DecLine, AccCurve, DecCurve);
|
||||
}
|
||||
else if (fabs(Speed) > 0.61)
|
||||
{
|
||||
@@ -6865,6 +6885,7 @@ int HSI_Motion::SpeedPercent(int AxisNum, double& Speed, int& DirveSpeed, int& S
|
||||
DecLine = m_JogDecLine[AxisNum][1];
|
||||
AccCurve = m_JogAccCurve[AxisNum][1];
|
||||
DecCurve = m_JogDecCurve[AxisNum][1];
|
||||
g_pLogger->SendAndFlushWithTime(L"[SpeedPercent] 0.61 DriveSpeed: [%d], StartSpeed: [%d], AccLine: [%d], DecLine: [%d], AccCurve: [%d], DecCurve: [%d]\n", DirveSpeed, StartSpeed, AccLine, DecLine, AccCurve, DecCurve);
|
||||
}
|
||||
else if (fabs(Speed) > 0.41)
|
||||
{
|
||||
@@ -6874,6 +6895,7 @@ int HSI_Motion::SpeedPercent(int AxisNum, double& Speed, int& DirveSpeed, int& S
|
||||
DecLine = m_JogDecLine[AxisNum][2];
|
||||
AccCurve = m_JogAccCurve[AxisNum][2];
|
||||
DecCurve = m_JogDecCurve[AxisNum][2];
|
||||
g_pLogger->SendAndFlushWithTime(L"[SpeedPercent] 0.41 DriveSpeed: [%d], StartSpeed: [%d], AccLine: [%d], DecLine: [%d], AccCurve: [%d], DecCurve: [%d]\n", DirveSpeed, StartSpeed, AccLine, DecLine, AccCurve, DecCurve);
|
||||
}
|
||||
else if (fabs(Speed) > 0.21)
|
||||
{
|
||||
@@ -6883,6 +6905,7 @@ int HSI_Motion::SpeedPercent(int AxisNum, double& Speed, int& DirveSpeed, int& S
|
||||
DecLine = m_JogDecLine[AxisNum][3];
|
||||
AccCurve = m_JogAccCurve[AxisNum][3];
|
||||
DecCurve = m_JogDecCurve[AxisNum][3];
|
||||
g_pLogger->SendAndFlushWithTime(L"[SpeedPercent] 0.21 DriveSpeed: [%d], StartSpeed: [%d], AccLine: [%d], DecLine: [%d], AccCurve: [%d], DecCurve: [%d]\n", DirveSpeed, StartSpeed, AccLine, DecLine, AccCurve, DecCurve);
|
||||
}
|
||||
else if (fabs(Speed) > 0.01)
|
||||
{
|
||||
@@ -6892,6 +6915,7 @@ int HSI_Motion::SpeedPercent(int AxisNum, double& Speed, int& DirveSpeed, int& S
|
||||
DecLine = m_JogDecLine[AxisNum][4];
|
||||
AccCurve = m_JogAccCurve[AxisNum][4];
|
||||
DecCurve = m_JogDecCurve[AxisNum][4];
|
||||
g_pLogger->SendAndFlushWithTime(L"[SpeedPercent] 0.01 DriveSpeed: [%d], StartSpeed: [%d], AccLine: [%d], DecLine: [%d], AccCurve: [%d], DecCurve: [%d]\n", DirveSpeed, StartSpeed, AccLine, DecLine, AccCurve, DecCurve);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user