获取运动参数和配置运动,档位调试
This commit is contained in:
@@ -92,7 +92,7 @@ void ErrorsHandler()
|
||||
{
|
||||
ErrorStr[Received] = '\0';
|
||||
printf("Motion Error: %d [%s]\n", ErrorCode, ErrorStr);
|
||||
g_pLogger->SendAndFlushWithTime(L"[ACS Motion] Motion Error %s\n",ErrorStr);
|
||||
g_pLogger->SendAndFlushWithTime(L"[ACS Motion] Motion Error %d%S\n", ErrorCode,ErrorStr);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -460,8 +460,7 @@ HSI_STATUS HSI_Motion::Startup(HWND _hWnd, bool _bOfflineOnly)
|
||||
{
|
||||
//尝试打开ACS控制器
|
||||
g_pLogger->SendAndFlushWithTime(L"[ACS Motion] In\n");
|
||||
g_pLogger->SendAndFlushWithTime(
|
||||
L"[ACS Motion] Wait for opening of communication with the controller... \n");
|
||||
g_pLogger->SendAndFlushWithTime(L"[ACS Motion] Wait for opening of communication with the controller... \n");
|
||||
|
||||
#ifdef OFFLINE //如果定义离线模式
|
||||
handleACS = acsc_OpenCommSimulator();
|
||||
@@ -501,7 +500,7 @@ HSI_STATUS HSI_Motion::Startup(HWND _hWnd, bool _bOfflineOnly)
|
||||
|
||||
|
||||
//获取ACS 控制器版本号, 待测试,2.70
|
||||
/*char Firmware[256];
|
||||
char Firmware[256];
|
||||
int Received;
|
||||
if (!acsc_GetFirmwareVersion(handleACS, Firmware, 255, &Received, nullptr))
|
||||
{
|
||||
@@ -509,13 +508,17 @@ HSI_STATUS HSI_Motion::Startup(HWND _hWnd, bool _bOfflineOnly)
|
||||
ErrorsHandler();
|
||||
}
|
||||
Firmware[Received-1] = '\0';
|
||||
g_pLogger->SendAndFlushWithTime(L"[ACS Motion] ACS Controller Version: %s\n", Firmware);*/
|
||||
//printf("%s", Firmware);
|
||||
|
||||
//https://www.cnblogs.com/MichaelOwen/articles/2128771.html
|
||||
//g_pLogger->SendAndFlushWithTime(L"%s%s\n", _T("[ACS Motion] ACS Controller Version: "), L"你好");
|
||||
g_pLogger->SendAndFlushWithTime(L"[ACS Motion] ACS Controller Version: %S\n", Firmware);
|
||||
|
||||
//获取SPiiPlus C Library version
|
||||
unsigned int Ver = acsc_GetLibraryVersion();
|
||||
printf("SPiiPlus C Library version is %d.%d.%d.%d\n", HIBYTE(HIWORD(Ver)), LOBYTE(HIWORD(Ver)),
|
||||
/* printf("SPiiPlus C Library version is %d.%d.%d.%d\n", HIBYTE(HIWORD(Ver)), LOBYTE(HIWORD(Ver)),
|
||||
HIBYTE(LOWORD(Ver)),
|
||||
LOBYTE(LOWORD(Ver)));
|
||||
LOBYTE(LOWORD(Ver)));*/
|
||||
g_pLogger->SendAndFlushWithTime(L"[ACS Motion] SPiiPlus C Library version is %d.%d.%d.%d\n",
|
||||
HIBYTE(HIWORD(Ver)), LOBYTE(HIWORD(Ver)), HIBYTE(LOWORD(Ver)),
|
||||
LOBYTE(LOWORD(Ver)));
|
||||
@@ -1843,7 +1846,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:[%lf]\n", AxisTypes, Speed);
|
||||
g_pLogger->SendAndFlushWithTime(L"[Jog] aixs: [%d] SpeedGear: [%lf]\n", AxisTypes, Speed);
|
||||
if (g_pHSI_Motion)
|
||||
{
|
||||
if (m_DeviceType != 3) //非转盘设备
|
||||
@@ -1851,7 +1854,13 @@ HSI_STATUS HSI_Motion::Jog(UINT AxisTypes, double Speed)
|
||||
m_Thread_StateJOGStop = HSI_THREAD_RUNNING;
|
||||
SetEvent(m_hTriggerEventJOGStop);
|
||||
}
|
||||
|
||||
int DriveSpeed(1);
|
||||
int StartSpeed(1);
|
||||
int AccLine(1);
|
||||
int DecLine(1);
|
||||
int AccCurve(1);
|
||||
int DecCurve(1);
|
||||
int JogSpeed(1);
|
||||
bool bJOGDir = Speed > 0 ? true : false; //运动方向
|
||||
byte AxisNumber = static_cast<byte>(AxisConvertIndex(AxisTypes));//Jog
|
||||
jogAxisNum = AxisNumber;
|
||||
@@ -1861,42 +1870,176 @@ HSI_STATUS HSI_Motion::Jog(UINT AxisTypes, double Speed)
|
||||
if (CurrentHomeMachineState == E_EF3_HOME_FINISHED)
|
||||
{
|
||||
//软限位
|
||||
g_pLogger->SendAndFlushWithTime(
|
||||
L"[Jog] Limit Enable, m_P_Work_Limit[AxisNumber] = %f,m_N_Work_Limit[AxisNumber] = %f\n",
|
||||
m_P_Work_Limit[AxisNumber], m_N_Work_Limit[AxisNumber]);
|
||||
}
|
||||
else
|
||||
{
|
||||
//无效软限位
|
||||
g_pLogger->SendAndFlushWithTime(L"[Jog] Limit No Enable\n");
|
||||
}
|
||||
|
||||
//是否回过家
|
||||
//if (m_Home_Machine_Axis[AxisNumber] == 0)
|
||||
//{
|
||||
// return rStatus;
|
||||
//}
|
||||
|
||||
// 是否启用急停
|
||||
//if ((StartSpeed < 250) && (DriveSpeed < 6))
|
||||
//{
|
||||
// m_IsUseJerk = 1;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// m_IsUseJerk = 0;
|
||||
//}
|
||||
//是否回过家判断
|
||||
if (m_Home_Machine_Axis[AxisNumber] == 0)
|
||||
{
|
||||
return rStatus;
|
||||
}
|
||||
|
||||
//设置 JOG运动参数 加减速 JOG_SPEED_ACC_DEC
|
||||
double now_pos[5] = { 0 };
|
||||
double Prf_pos[5] = { 0 };
|
||||
double limitpos[4] = { 0 };
|
||||
int RemainPul = 0;
|
||||
int limitSDPul = 0;
|
||||
double time;
|
||||
/*GetPositionXyz(1, now_pos[0], now_pos[1], now_pos[2], time);*/
|
||||
GetPositionEncPrfMulti(1, now_pos, Prf_pos, 1);
|
||||
|
||||
|
||||
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);
|
||||
|
||||
if (m_DeviceType != 3)
|
||||
{
|
||||
if (AxisTypes == AXIS_X /*&& m_motorType & 0x01*/)
|
||||
{
|
||||
if (!bJOGDir) //负方向
|
||||
{
|
||||
RemainPul = static_cast<int>(now_pos[1] / m_Resolution[1]) - static_cast<int>(m_N_Work_Limit[1] /
|
||||
m_Resolution[1]);
|
||||
limitSDPul = (DriveSpeed - StartSpeed) * 13;
|
||||
if ((RemainPul < limitSDPul * 2) && (RemainPul > 0))
|
||||
{
|
||||
float SpeedRatio = limitSDPul * 2 / RemainPul;
|
||||
DriveSpeed = DriveSpeed / SpeedRatio;
|
||||
if (DriveSpeed < StartSpeed)
|
||||
{
|
||||
DriveSpeed = StartSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RemainPul = static_cast<int>(m_P_Work_Limit[1] / m_Resolution[1]) - static_cast<int>(now_pos[1] /
|
||||
m_Resolution[1]);
|
||||
limitSDPul = (DriveSpeed - StartSpeed) * 13;
|
||||
if ((RemainPul < limitSDPul * 2) && (RemainPul > 0))
|
||||
{
|
||||
float SpeedRatio = limitSDPul * 2 / RemainPul;
|
||||
DriveSpeed = DriveSpeed / SpeedRatio;
|
||||
if (DriveSpeed < StartSpeed)
|
||||
{
|
||||
DriveSpeed = StartSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (AxisTypes == AXIS_Y /*&& m_motorType & 0x02*/)
|
||||
{
|
||||
if (!bJOGDir) //负方向
|
||||
{
|
||||
RemainPul = static_cast<int>(now_pos[2] / m_Resolution[2]) - static_cast<int>(m_N_Work_Limit[2] /
|
||||
m_Resolution[2]);
|
||||
limitSDPul = (DriveSpeed - StartSpeed) * 13;
|
||||
if ((RemainPul < limitSDPul * 2) && (RemainPul > 0))
|
||||
{
|
||||
float SpeedRatio = 1 + limitSDPul * 2 / RemainPul;
|
||||
DriveSpeed = DriveSpeed / SpeedRatio;
|
||||
if (DriveSpeed < StartSpeed)
|
||||
{
|
||||
DriveSpeed = StartSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RemainPul = static_cast<int>(m_P_Work_Limit[2] / m_Resolution[2]) - static_cast<int>(now_pos[2] /
|
||||
m_Resolution[2]);
|
||||
limitSDPul = (DriveSpeed - StartSpeed) * 13;
|
||||
if ((RemainPul < limitSDPul * 2) && (RemainPul > 0))
|
||||
{
|
||||
float SpeedRatio = limitSDPul * 2 / RemainPul;
|
||||
DriveSpeed = DriveSpeed / SpeedRatio;
|
||||
if (DriveSpeed < StartSpeed)
|
||||
{
|
||||
DriveSpeed = StartSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (AxisTypes == AXIS_Z /*&& m_motorType & 0x04*/)
|
||||
{
|
||||
if (!bJOGDir) //负方向
|
||||
{
|
||||
RemainPul = static_cast<int>(now_pos[3] / m_Resolution[3]) - static_cast<int>(m_N_Work_Limit[3] /
|
||||
m_Resolution[3]);
|
||||
limitSDPul = (DriveSpeed - StartSpeed) * 13;
|
||||
if ((RemainPul < limitSDPul * 2) && (RemainPul > 0))
|
||||
{
|
||||
float SpeedRatio = limitSDPul * 2 / RemainPul;
|
||||
DriveSpeed = DriveSpeed / SpeedRatio;
|
||||
if (DriveSpeed < StartSpeed)
|
||||
{
|
||||
DriveSpeed = StartSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RemainPul = static_cast<int>(m_P_Work_Limit[3] / m_Resolution[3]) - static_cast<int>(now_pos[3] /
|
||||
m_Resolution[3]);
|
||||
limitSDPul = (DriveSpeed - StartSpeed) * 13;
|
||||
if ((RemainPul < limitSDPul * 2) && (RemainPul > 0))
|
||||
{
|
||||
float SpeedRatio = limitSDPul * 2 / RemainPul;
|
||||
DriveSpeed = DriveSpeed / SpeedRatio;
|
||||
if (DriveSpeed < StartSpeed)
|
||||
{
|
||||
DriveSpeed = StartSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//速度限制
|
||||
g_pLogger->SendAndFlushWithTime(L"[Jog] StartSpeed: [%d], DriveSpeed: [%d], AccCurve: [%d], AccLine: [%d], DecCurve: [%d], DecLine: [%d]\n", StartSpeed, DriveSpeed, AccCurve, AccLine, DecCurve, DecLine);
|
||||
|
||||
// 急停判断
|
||||
if ((StartSpeed < 250) && (DriveSpeed < 6))
|
||||
{
|
||||
m_IsUseJerk = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_IsUseJerk = 0;
|
||||
}
|
||||
|
||||
//打印当前轴的速度
|
||||
double motionParam[5] = { 0 };
|
||||
GetMotorParam(jogAxisNum, motionParam);
|
||||
g_pLogger->SendAndFlushWithTime(
|
||||
L"[Jog] Axis= %d, Velocity = %.2f, Acceleration= %.2f, Deceleration= %.2f, KillDeceleration= %.2f, Jerk= %.2f\n",
|
||||
jogAxisNum, motionParam[0], motionParam[1], motionParam[2], motionParam[3], motionParam[4]);
|
||||
|
||||
//开始JOG运动
|
||||
int acsDirection = bJOGDir ? ACSC_POSITIVE_DIRECTION : ACSC_NEGATIVE_DIRECTION; //正方向,或 负方向
|
||||
if (!acsc_Jog(handleACS, 0, jogAxisNum, acsDirection, nullptr))
|
||||
if (!bJOGDir)
|
||||
{
|
||||
StartSpeed = StartSpeed * (-1); // Negative direction : Using - (minus) velocity
|
||||
}
|
||||
//int acsDirection = bJOGDir ? ACSC_POSITIVE_DIRECTION : ACSC_NEGATIVE_DIRECTION; //正方向,或 负方向
|
||||
if (!acsc_Jog(handleACS, 0, jogAxisNum, StartSpeed, nullptr))
|
||||
{
|
||||
printf("[Jog] 轴[%d] [%s] 方向移动失败", AxisTypes, bJOGDir? "正" : "负");
|
||||
g_pLogger->SendAndFlushWithTime(L"[Jog] aixs:[%d] JOGDir:[%s] Jog move failed\n", AxisTypes, bJOGDir ? "P" : "N");
|
||||
g_pLogger->SendAndFlushWithTime(L"[Jog] failed, Aixs:[%d] JOGDir:[%S]\n", AxisTypes, bJOGDir ? "Positive" : "Negative");
|
||||
ErrorsHandler();
|
||||
}
|
||||
|
||||
|
||||
jogMoving = true;
|
||||
g_pLogger->SendAndFlushWithTime(L"[Jog] Out, bJOGDir = %s\n", bJOGDir? "positive":"negative");
|
||||
g_pLogger->SendAndFlushWithTime(L"[Jog] Out, StartSpeed = %d\n", StartSpeed);
|
||||
}
|
||||
return rStatus;
|
||||
}
|
||||
@@ -2375,14 +2518,14 @@ int HSI_Motion::P2P(short AxisNumber, long Pos, double Speed, double Acc)
|
||||
//===========================================================================
|
||||
//运动控制部分
|
||||
//===========================================================================
|
||||
HSI_STATUS HSI_Motion::GetPositionEncPrfMulti(UINT AxisTypes, double* EncPos, double* PrfPos, int Count)
|
||||
HSI_STATUS HSI_Motion::GetPositionEncPrfMultiOld(UINT AxisTypes, double* EncPos, double* PrfPos, int Count)
|
||||
{
|
||||
auto rStatus = HSI_STATUS_NORMAL;
|
||||
UNREFERENCED_PARAMETER(AxisTypes);
|
||||
CString tempStr;
|
||||
if (g_pHSI_Motion)
|
||||
{
|
||||
//g_pLogger->SendAndFlushWithTime(L"[GetPositionEncPrfMulti] In\n");
|
||||
g_pLogger->SendAndFlushWithTime(L"[GetPositionEncPrfMulti] In\n");
|
||||
if (m_SO7_Serial.m_RecvData[0] == 2)
|
||||
{
|
||||
EncPos[1] = (m_SO7_Serial.m_RecvData[1] << 24 | m_SO7_Serial.m_RecvData[2] << 16 | m_SO7_Serial.m_RecvData[
|
||||
@@ -2442,11 +2585,81 @@ HSI_STATUS HSI_Motion::GetPositionEncPrfMulti(UINT AxisTypes, double* EncPos, do
|
||||
PrfPos[4] = m_PrfPos[4];
|
||||
g_pLogger->SendAndFlushWithTime(L"[GetPositionEncPrfMulti] failed\n");
|
||||
}
|
||||
//g_pLogger->SendAndFlushWithTime(L"[GetPositionEncPrfMulti] Out\n");
|
||||
g_pLogger->SendAndFlushWithTime(L"[GetPositionEncPrfMulti] Out\n");
|
||||
}
|
||||
return rStatus;
|
||||
}
|
||||
HSI_STATUS HSI_Motion::GetPositionEncPrfMulti(UINT AxisTypes, double* EncPos, double* PrfPos, int Count)
|
||||
{
|
||||
auto rStatus = HSI_STATUS_NORMAL;
|
||||
UNREFERENCED_PARAMETER(AxisTypes);
|
||||
CString tempStr;
|
||||
if (g_pHSI_Motion)
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[GetPositionEncPrfMulti] In\n");
|
||||
if (m_SO7_Serial.m_RecvData[0] == 2)
|
||||
{
|
||||
EncPos[1] = (m_SO7_Serial.m_RecvData[1] << 24 | m_SO7_Serial.m_RecvData[2] << 16 | m_SO7_Serial.m_RecvData[
|
||||
3] << 8 | m_SO7_Serial.m_RecvData[4]) * m_Resolution[1];
|
||||
EncPos[2] = (m_SO7_Serial.m_RecvData[5] << 24 | m_SO7_Serial.m_RecvData[6] << 16 | m_SO7_Serial.m_RecvData[
|
||||
7] << 8 | m_SO7_Serial.m_RecvData[8]) * m_Resolution[2];
|
||||
EncPos[3] = (m_SO7_Serial.m_RecvData[9] << 24 | m_SO7_Serial.m_RecvData[10] << 16 | m_SO7_Serial.m_RecvData[
|
||||
11] << 8 | m_SO7_Serial.m_RecvData[12]) * m_Resolution[3];
|
||||
EncPos[4] = (m_SO7_Serial.m_RecvData[13] << 24 | m_SO7_Serial.m_RecvData[14] << 16 | m_SO7_Serial.m_RecvData
|
||||
[15] << 8 | m_SO7_Serial.m_RecvData[16]) * m_Resolution[4];
|
||||
|
||||
PrfPos[1] = (m_SO7_Serial.m_RecvData[17] << 24 | m_SO7_Serial.m_RecvData[18] << 16 | m_SO7_Serial.m_RecvData
|
||||
[19] << 8 | m_SO7_Serial.m_RecvData[20]) * m_Resolution[1];
|
||||
PrfPos[2] = (m_SO7_Serial.m_RecvData[21] << 24 | m_SO7_Serial.m_RecvData[22] << 16 | m_SO7_Serial.m_RecvData
|
||||
[23] << 8 | m_SO7_Serial.m_RecvData[24]) * m_Resolution[2];
|
||||
PrfPos[3] = (m_SO7_Serial.m_RecvData[25] << 24 | m_SO7_Serial.m_RecvData[26] << 16 | m_SO7_Serial.m_RecvData
|
||||
[27] << 8 | m_SO7_Serial.m_RecvData[28]) * m_Resolution[3];
|
||||
PrfPos[4] = (m_SO7_Serial.m_RecvData[29] << 24 | m_SO7_Serial.m_RecvData[30] << 16 | m_SO7_Serial.m_RecvData
|
||||
[31] << 8 | m_SO7_Serial.m_RecvData[32]) * m_Resolution[4];
|
||||
|
||||
if (m_IsHavePattern & 0x01)
|
||||
m_EncPos[1] = EncPos[1];
|
||||
else
|
||||
m_EncPos[1] = PrfPos[1];
|
||||
if (m_IsHavePattern & 0x02)
|
||||
m_EncPos[2] = EncPos[2];
|
||||
else
|
||||
m_EncPos[2] = PrfPos[2];
|
||||
if (m_IsHavePattern & 0x04)
|
||||
m_EncPos[3] = EncPos[3];
|
||||
else
|
||||
m_EncPos[3] = PrfPos[3];
|
||||
if (m_IsHavePattern & 0x08)
|
||||
m_EncPos[4] = EncPos[4];
|
||||
else
|
||||
m_EncPos[4] = PrfPos[4];
|
||||
|
||||
m_PrfPos[1] = PrfPos[1];
|
||||
m_PrfPos[2] = PrfPos[2];
|
||||
m_PrfPos[3] = PrfPos[3];
|
||||
m_PrfPos[4] = PrfPos[4];
|
||||
|
||||
//begin_position[1] = EncPos[1] / m_Resolution[1];
|
||||
//begin_position[2] = EncPos[2] / m_Resolution[1];
|
||||
//begin_position[3] = EncPos[3] / m_Resolution[1];
|
||||
//begin_position[4] = EncPos[4] / m_Resolution[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
EncPos[1] = m_EncPos[1];
|
||||
EncPos[2] = m_EncPos[2];
|
||||
EncPos[2] = m_EncPos[3];
|
||||
EncPos[4] = m_EncPos[4];
|
||||
PrfPos[1] = m_PrfPos[1];
|
||||
PrfPos[2] = m_PrfPos[2];
|
||||
PrfPos[2] = m_PrfPos[3];
|
||||
PrfPos[4] = m_PrfPos[4];
|
||||
g_pLogger->SendAndFlushWithTime(L"[GetPositionEncPrfMulti] failed\n");
|
||||
}
|
||||
g_pLogger->SendAndFlushWithTime(L"[GetPositionEncPrfMulti] Out\n");
|
||||
}
|
||||
return rStatus;
|
||||
}
|
||||
//===========================================================================
|
||||
/**
|
||||
* \brief 获取轴当前运动位置
|
||||
@@ -3283,11 +3496,12 @@ HSI_STATUS HSI_Motion::SetPositionXyz(UINT AxisTypes, double PositionX, double P
|
||||
PositionY, PositionZ);*/
|
||||
|
||||
//打印轴当前运动参数
|
||||
double* motionParam[5] = {0};
|
||||
GetMotorParam(ACSC_AXIS_0, motionParam);
|
||||
byte AxisNumber = static_cast<byte>(AxisConvertIndex(AxisTypes));//轴号换算
|
||||
double motionParam[5] = {0};
|
||||
GetMotorParam(AxisNumber, motionParam);
|
||||
g_pLogger->SendAndFlushWithTime(
|
||||
L"[SetPositionXyz] axis= %d, GetVelocity = %d,GetAcceleration= %d,GetDeceleration= %d, GetKillDeceleration= %d, GetJerk= %d\n",
|
||||
AXIS_X, motionParam[0], motionParam[1], motionParam[2], motionParam[3], motionParam[4]);
|
||||
L"[SetPositionXyz] Axis= %.2f, Velocity = %.2f, Acceleration= %.2f, Deceleration= %.2f, KillDeceleration= %.2f, Jerk= %.2f\n",
|
||||
jogAxisNum, motionParam[0], motionParam[1], motionParam[2], motionParam[3], motionParam[4]);
|
||||
|
||||
//设置轴运动速度,TO-DO
|
||||
|
||||
@@ -3377,42 +3591,46 @@ int HSI_Motion::CaculateStepMotorACC(int pos, int maxacc, int minacc)
|
||||
//void func2(uchar* s); //利用指针返回数组
|
||||
//uchar* func1(); //利用指针函数返回数组
|
||||
//void func0(uchar*& r); //利用引用返回数组
|
||||
HSI_STATUS HSI_Motion::GetMotorParam(int AXIS, double* motionParam[5])
|
||||
HSI_STATUS HSI_Motion::GetMotorParam(int AXIS, double motionParam[5])
|
||||
{
|
||||
auto rStatus = HSI_STATUS_NORMAL;
|
||||
if (handleACS != ACSC_INVALID)
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] In\n");
|
||||
|
||||
//依次是 速度、加速度、减速、杀死速度、抖动
|
||||
if (!acsc_GetVelocity(handleACS, AXIS, motionParam[0], nullptr))
|
||||
if (!acsc_GetVelocity(handleACS, AXIS, motionParam+0, nullptr))
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] acsc_GetVelocity error\n");
|
||||
rStatus = HSI_ACS_ERROR;
|
||||
ErrorsHandler();
|
||||
}
|
||||
if (!acsc_GetAcceleration(handleACS, AXIS, motionParam[1], nullptr))
|
||||
|
||||
if (!acsc_GetAcceleration(handleACS, AXIS, motionParam+1, nullptr))
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] acsc_GetAcceleration error\n");
|
||||
rStatus = HSI_ACS_ERROR;
|
||||
ErrorsHandler();
|
||||
}
|
||||
if (!acsc_GetDeceleration(handleACS, AXIS, motionParam[2], nullptr))
|
||||
if (!acsc_GetDeceleration(handleACS, AXIS, motionParam+2, nullptr))
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] acsc_GetDeceleration error\n");
|
||||
rStatus = HSI_ACS_ERROR;
|
||||
ErrorsHandler();
|
||||
}
|
||||
if (!acsc_GetKillDeceleration(handleACS, AXIS, motionParam[3], nullptr))
|
||||
if (!acsc_GetKillDeceleration(handleACS, AXIS, motionParam+3, nullptr))
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] acsc_GetKillDeceleration error\n");
|
||||
rStatus = HSI_ACS_ERROR;
|
||||
ErrorsHandler();
|
||||
}
|
||||
if (!acsc_GetJerk(handleACS, AXIS, motionParam[4], nullptr))
|
||||
if (!acsc_GetJerk(handleACS, AXIS, motionParam+4, nullptr))
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] acsc_GetJerk error\n");
|
||||
rStatus = HSI_ACS_ERROR;
|
||||
ErrorsHandler();
|
||||
}
|
||||
g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] Out\n");
|
||||
}
|
||||
|
||||
return rStatus;
|
||||
@@ -6967,14 +7185,14 @@ short HSI_Motion::AxisConvertIndex(UINT AxisTypes)
|
||||
AxisNumber = 0x04;
|
||||
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,
|
||||
g_pLogger->SendAndFlushWithTime(L"[AxisConvertIndex] failed, AxisTypes = %d,AxisNumber = %d\n", AxisTypes,
|
||||
AxisNumber);
|
||||
break;
|
||||
}
|
||||
@@ -7074,6 +7292,7 @@ HSI_STATUS HSI_Motion::GetPositionEx(UINT AxisTypes, double& Position, double& T
|
||||
double position[4] = {0.0};
|
||||
short AxisNumber = AxisConvertIndex(AxisTypes);
|
||||
Position = m_PosForAllAxis[AxisNumber];
|
||||
g_pLogger->SendAndFlushWithTime(L"[GetPositionEx] Position: %d\n", Position);
|
||||
}
|
||||
return rStatus;
|
||||
}
|
||||
@@ -7329,6 +7548,7 @@ HSI_STATUS HSI_Motion::GetAccelerationEx(UINT AxisTypes, double& Accel)
|
||||
Accel = m_SetPotion_StartSpeed[AxisNumber] * (m_Resolution[AxisNumber] * 500);
|
||||
}
|
||||
}
|
||||
g_pLogger->SendAndFlushWithTime(L"[GetAccelerationEx] Accel = %d\n", Accel);
|
||||
return rStatus;
|
||||
}
|
||||
|
||||
@@ -7352,6 +7572,7 @@ HSI_STATUS HSI_Motion::SetAccelerationEx(UINT AxisTypes, double Accel)
|
||||
m_SetPotion_StartSpeed[AxisNumber] = static_cast<int>(Accel / (m_Resolution[AxisNumber] * 500));
|
||||
}
|
||||
}
|
||||
g_pLogger->SendAndFlushWithTime(L"[SetAccelerationEx] Accel = %d\n", m_SetPotion_StartSpeed[AxisNumber]);
|
||||
return rStatus;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user