运动错误事件触发上层;回家功能移植到 ishomed函数中;对 EF3版本号读取测试;

This commit is contained in:
zhengxuan.zhang
2024-02-27 16:31:47 +08:00
parent e086e9cea3
commit 7bcf86d55f
23 changed files with 65 additions and 50 deletions
-1
View File
@@ -165,7 +165,6 @@ HSI_API HSI_STATUS WINAPI HSI_MOTION_STARTUP(bool bHome)
{ {
return HSI_STATUS_FAILED; return HSI_STATUS_FAILED;
} }
//rStatus = g_pHSI_Motion->HomeMachine(bHome);
switch (g_pHSI_Motion->m_iJoyStick) //摇杆设置 switch (g_pHSI_Motion->m_iJoyStick) //摇杆设置
{ {
case 0: case 0:
+1 -1
View File
@@ -21,7 +21,7 @@
#endif #endif
const int HSI_APIVersionMajor = 1; const int HSI_APIVersionMajor = 1;
const int HSI_APIVersionMinor = 10; const int HSI_APIVersionMinor = 9;
const int HSI_MaxStringLength = 255; // Maximum string length (buffer size - 1) const int HSI_MaxStringLength = 255; // Maximum string length (buffer size - 1)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Interface API // Interface API
+2 -1
View File
@@ -70,7 +70,8 @@
<AdditionalLibraryDirectories>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x64;$(LocalDebuggerWorkingDirectory)\ACS;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x64;$(LocalDebuggerWorkingDirectory)\ACS;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command>copy "$(TargetDir)$(ProjectName).dll" "$(SolutionDir)HSI_SEVENOCEAN_EF1_CsTest\bin\Debug\HSI.dll"</Command> <Command>copy "$(TargetDir)$(ProjectName).dll" "$(SolutionDir)HSI_SEVENOCEAN_EF1_CsTest\bin\Debug\HSI.dll"
copy "$(TargetDir)$(ProjectName).dll" "C:\Program Files\Hexagon\Metus\Metus-7.10.1967\HSI_Sevenocean_EF3.dll" </Command>
</PostBuildEvent> </PostBuildEvent>
<PreBuildEvent> <PreBuildEvent>
<Command>version.cmd</Command> <Command>version.cmd</Command>
+31 -20
View File
@@ -67,7 +67,7 @@ int HSI_Motion::m_ThreadTCP_State = TCPIP_THREAD_PAUSED;
SOCKET m_socket[4] = {0}; SOCKET m_socket[4] = {0};
void ErrorsHandler() void HSI_Motion::ErrorsHandler()
{ {
if (handleACS != ACSC_INVALID) if (handleACS != ACSC_INVALID)
{ {
@@ -85,6 +85,15 @@ void ErrorsHandler()
ErrorStr[Received] = '\0'; ErrorStr[Received] = '\0';
printf("Motion Error: %d [%s]\n", ErrorCode, ErrorStr); printf("Motion Error: %d [%s]\n", ErrorCode, ErrorStr);
g_pLogger->SendAndFlushWithTime(L"[ACS Motion] Motion Error,Code: %d, %S\n", ErrorCode, ErrorStr); g_pLogger->SendAndFlushWithTime(L"[ACS Motion] Motion Error,Code: %d, %S\n", ErrorCode, ErrorStr);
//向上层发送错误信息
sEvenProp.Init();
sEvenProp.EventType = HSI_EVENT_FUNCTION;
sEvenProp.EventID = HSI_EVENT_DEBUG_LOG;
sEvenProp.EventResponse = HSI_EVENT_FUNCTION_FAILED;
EventCallback(sEvenProp);
g_pLogger->SendAndFlushWithTime(L"[ACS Motion] Motion Error Event Set\n");
} }
} }
else else
@@ -245,7 +254,7 @@ HSI_Motion::HSI_Motion()
m_Home_Pos_Axis[i] = 0; //记住关闭电源时的位置,用于判断是否还需要回原点 m_Home_Pos_Axis[i] = 0; //记住关闭电源时的位置,用于判断是否还需要回原点
} }
m_Home_Machine_Axis[4] = 0; //用于启动时需要回原点的轴号选择 //m_Home_Machine_Axis[4] = 0; //用于启动时需要回原点的轴号选择
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
m_N_Work_Limit[i] = -40; //负限位 m_N_Work_Limit[i] = -40; //负限位
@@ -1071,7 +1080,7 @@ HSI_STATUS HSI_Motion::HomeMachine(bool bHomed)
g_pLogger->SendAndFlushWithTime(L"[HomeMachine] bHomed No Need Reture\n"); g_pLogger->SendAndFlushWithTime(L"[HomeMachine] bHomed No Need Reture\n");
return HSI_STATUS_NORMAL; return HSI_STATUS_NORMAL;
} }
if (m_IsUseEF3 == 0) if (m_IsUseEF3 == 0) //不启用EF3的情况
{ {
return HSI_STATUS_NORMAL; return HSI_STATUS_NORMAL;
} }
@@ -1542,6 +1551,9 @@ HSI_STATUS HSI_Motion::IsHomed(bool& bHomed)
g_pLogger->SendAndFlushWithTime(L"[IsHomed] Is No Go Home E_GTS_HOME_NONE\n"); g_pLogger->SendAndFlushWithTime(L"[IsHomed] Is No Go Home E_GTS_HOME_NONE\n");
CurrentHomeMachineState = E_EF3_HOME_NONE; CurrentHomeMachineState = E_EF3_HOME_NONE;
bHomed = false; bHomed = false;
//如果各个轴标志位 未回过家,需要回家
rStatus = g_pHSI_Motion->HomeMachine(TRUE); //执行回家
} }
g_pLogger->SendAndFlushWithTime(L"[IsHomed] Out\n"); g_pLogger->SendAndFlushWithTime(L"[IsHomed] Out\n");
} }
@@ -3552,7 +3564,7 @@ HSI_STATUS HSI_Motion::SetPositionXyz(UINT AxisTypes, double PositionX, double P
if (g_pHSI_Motion) if (g_pHSI_Motion)
{ {
g_pLogger->SendAndFlushWithTime(L"[SetPositionXyz] In\n"); g_pLogger->SendAndFlushWithTime(L"[SetPositionXyz] In\n");
g_pLogger->SendAndFlushWithTime(L"[SetPositionXyz] Pos[1] = %.4f,Pos[2] = %.4f,Pos[3] = %.4f\n", PositionX, g_pLogger->SendAndFlushWithTime(L"[SetPositionXyz] AxisTypes = %d, PositionX = %.4f,PositionY = %.4f,PositionZ = %.4f\n", AxisTypes,PositionX,
PositionY, PositionZ); PositionY, PositionZ);
axis_start = 0; axis_start = 0;
@@ -3577,18 +3589,16 @@ HSI_STATUS HSI_Motion::SetPositionXyz(UINT AxisTypes, double PositionX, double P
m_PosThread[4] = m_PositionA; m_PosThread[4] = m_PositionA;
//打印当前位置,目标位置 //打印当前位置,目标位置
/* g_pLogger->SendAndFlushWithTime( g_pLogger->SendAndFlushWithTime(
L"[SetPositionXyzNowPos] Pos[1] = %.4f,Pos[2] = %.4f,Pos[3] = %.4f,Pos[4] = %.4f, Resolution[1] = %.4f\n", L"[SetPositionXyz] Pos[1] = %.4f,Pos[2] = %.4f,Pos[3] = %.4f,Pos[4] = %.4f, Resolution[1] = %.4f\n",
m_PosThread[1] * m_Resolution[1], m_PosThread[2] * m_Resolution[2], m_PosThread[3] * m_Resolution[3], m_PosThread[1] * m_Resolution[1], m_PosThread[2] * m_Resolution[2], m_PosThread[3] * m_Resolution[3],
m_PosThread[4] * m_Resolution[4], m_Resolution[1]); m_PosThread[4] * m_Resolution[4], m_Resolution[1]);
g_pLogger->SendAndFlushWithTime( g_pLogger->SendAndFlushWithTime(L"[SetPositionXyz] Pos[1] = %.4f, Pos[2] = %.4f, Pos[3] = %.4f\n", PositionX,PositionY, PositionZ);
L"[SetPositionXyzTagPos] Pos[1] = %.4f, Pos[2] = %.4f, Pos[3] = %.4f\n", PositionX,
PositionY, PositionZ);*/
//打印轴当前运动参数 //打印轴当前运动参数
byte AxisNumber = static_cast<byte>(AxisConvertIndex(AxisTypes)); //轴号换算 byte AxisNumber = static_cast<byte>(AxisConvertIndex(AxisTypes)); //轴号换算
double motionParam[5] = {0}; double motionParam[5] = {0};
GetMotorParam(AxisNumber, motionParam); GetMotorParam(AxisNumber, motionParam); //获取单轴运动参数
g_pLogger->SendAndFlushWithTime( g_pLogger->SendAndFlushWithTime(
L"[SetPositionXyz] Axis= %.2f, Velocity = %.2f, Acceleration= %.2f, Deceleration= %.2f, KillDeceleration= %.2f, Jerk= %.2f\n", 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]); jogAxisNum, motionParam[0], motionParam[1], motionParam[2], motionParam[3], motionParam[4]);
@@ -3605,9 +3615,6 @@ HSI_STATUS HSI_Motion::SetPositionXyz(UINT AxisTypes, double PositionX, double P
ErrorsHandler(); ErrorsHandler();
} }
//启动插补和定位功能
//圆弧插补
//状态更新 //状态更新
if (eType == HSI_MOTION_MOVE_NOWAIT) //非等待 if (eType == HSI_MOTION_MOVE_NOWAIT) //非等待
@@ -3676,7 +3683,7 @@ int HSI_Motion::CaculateStepMotorACC(int pos, int maxacc, int minacc)
//void func0(uchar*& r); //利用引用返回数组 //void func0(uchar*& r); //利用引用返回数组
/** /**
* \brief * \brief
* \param AXIS * \param AXIS
* \param motionParam * \param motionParam
* \return * \return
@@ -3688,32 +3695,35 @@ HSI_STATUS HSI_Motion::GetMotorParam(int AXIS, double motionParam[5])
{ {
g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] In\n"); 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"); g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] acsc_GetVelocity error\n");
rStatus = HSI_ACS_ERROR; rStatus = HSI_ACS_ERROR;
ErrorsHandler(); 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"); g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] acsc_GetAcceleration error\n");
rStatus = HSI_ACS_ERROR; rStatus = HSI_ACS_ERROR;
ErrorsHandler(); 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"); g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] acsc_GetDeceleration error\n");
rStatus = HSI_ACS_ERROR; rStatus = HSI_ACS_ERROR;
ErrorsHandler(); 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"); g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] acsc_GetKillDeceleration error\n");
rStatus = HSI_ACS_ERROR; rStatus = HSI_ACS_ERROR;
ErrorsHandler(); 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"); g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] acsc_GetJerk error\n");
@@ -7571,6 +7581,7 @@ HSI_STATUS HSI_Motion::GetPntsDistance(double& pDistance, int& spTimeCount)
int HSI_Motion::SpeedPercent(int AxisNum, double& Speed, int& DirveSpeed, int& StartSpeed, int& AccLine, int& DecLine, int HSI_Motion::SpeedPercent(int AxisNum, double& Speed, int& DirveSpeed, int& StartSpeed, int& AccLine, int& DecLine,
int& AccCurve, int& DecCurve) int& AccCurve, int& DecCurve)
{ {
g_pLogger->SendAndFlushWithTime(L"[SpeedPercent] AxisNum: [%d]\n", AxisNum);
int MovetoSpeedGear = 0; int MovetoSpeedGear = 0;
int flag = 1; int flag = 1;
if (fabs(Speed) > 1.01) if (fabs(Speed) > 1.01)
@@ -7847,14 +7858,14 @@ HSI_STATUS HSI_Motion::SetAccelerationXyz(double AccelX, double AccelY, double A
} }
//=========================================================================== //===========================================================================
double HSI_Motion::LimitOver(UINT AxisTypes, double& LimitPos) double HSI_Motion::LimitOver(UINT AxisTypes, double& LimitPos) //单轴软限位
{ {
short AxisNumber = AxisConvertIndex(AxisTypes); short AxisNumber = AxisConvertIndex(AxisTypes);
if (g_pHSI_Motion) if (g_pHSI_Motion)
{ {
switch (AxisNumber) switch (AxisNumber)
{ {
case 1: //轴1 case 1: // X
{ {
if (LimitPos >= m_P_Work_Limit[1]) if (LimitPos >= m_P_Work_Limit[1])
{ {
@@ -7866,7 +7877,7 @@ double HSI_Motion::LimitOver(UINT AxisTypes, double& LimitPos)
} }
break; break;
} }
case 2: case 2: //Y 轴
{ {
if (LimitPos >= m_P_Work_Limit[2]) if (LimitPos >= m_P_Work_Limit[2])
{ {
@@ -7890,7 +7901,7 @@ double HSI_Motion::LimitOver(UINT AxisTypes, double& LimitPos)
} }
break; break;
} }
case 4: case 4: //Z轴
{ {
if (LimitPos >= m_P_Work_Limit[4]) if (LimitPos >= m_P_Work_Limit[4])
{ {
+2 -1
View File
@@ -644,6 +644,7 @@ public:
HSI_STATUS SpecialMotorHome(short AxisNum); HSI_STATUS SpecialMotorHome(short AxisNum);
HSI_STATUS SpecialMotorMove(short AxisNum, double Position); HSI_STATUS SpecialMotorMove(short AxisNum, double Position);
void ErrorsHandler();
private: private:
UINT ActiveAxis; UINT ActiveAxis;
int iaxisNum; int iaxisNum;
@@ -685,6 +686,6 @@ private:
}; };
extern HSI_Motion* g_pHSI_Motion; extern HSI_Motion* g_pHSI_Motion;
extern void ErrorsHandler(const char* ErrorMessage, BOOL fCloseComm); //ACS ´íÎó´òÓ¡ //extern void ErrorsHandler(const char* ErrorMessage, BOOL fCloseComm); //ACS ´íÎó´òÓ¡
#endif #endif
+2 -2
View File
@@ -12,5 +12,5 @@
#define HSI_VERSION_REVNUM #define HSI_VERSION_REVNUM
#define HSI_VERSION_BUILD_DATE _T(__DATE__ ) #define HSI_VERSION_BUILD_DATE _T(__DATE__ )
#define HSI_VERSION_BUILD_TIME _T(__TIME__ ) #define HSI_VERSION_BUILD_TIME _T(__TIME__ )
#define HSI_FILE_DESCRIPTION "2024.02.26 / 16:16 " #define HSI_FILE_DESCRIPTION "2024.02.27 / 16:28 "
#define HSI_FILE_CSDESCRIPTION _T("2024.02.26 / 16:16 ") #define HSI_FILE_CSDESCRIPTION _T("2024.02.27 / 16:28 ")
Binary file not shown.
Binary file not shown.
+3 -1
View File
@@ -63,7 +63,9 @@ namespace HSI_SEVENOCEAN_EF1_CsTest.HSI
{ {
case HSI_EVENT_TYPE.HSI_EVENT_NONE: case HSI_EVENT_TYPE.HSI_EVENT_NONE:
break; break;
case HSI_EVENT_TYPE.HSI_EVENT_ERROR: case HSI_EVENT_TYPE.HSI_EVENT_ERROR: //´íÎó
MessageBox.Show(eventData, Resources.Interface_Tips,
msgBtn, MessageBoxIcon.Error);
break; break;
case HSI_EVENT_TYPE.HSI_EVENT_FUNCTION: case HSI_EVENT_TYPE.HSI_EVENT_FUNCTION:
var eventFunctionId = (HSI_EVENT_FUNCTION_ID)eventId; var eventFunctionId = (HSI_EVENT_FUNCTION_ID)eventId;
+24 -23
View File
@@ -43,33 +43,34 @@ namespace HSI_SEVENOCEAN_EF1_CsTest
Console.WriteLine("Motion.Startup:{0}", rStatus); Console.WriteLine("Motion.Startup:{0}", rStatus);
//5 获取EF3固件版本号,待测试 //5 获取EF3固件版本号,待测试
//var EF3Version = new byte[20]; var EF3Version = new byte[20];
//IntPtr intPtrEF3Version = Marshal.StringToHGlobalAnsi(""); IntPtr intPtrEF3Version = Marshal.StringToHGlobalAnsi("");
//rStatus = Interface.MotionGetFirewareVerion(intPtrEF3Version); rStatus = Interface.MotionGetFirewareVerion(intPtrEF3Version);
//Console.WriteLine("Interface.MotionGetFirewareVerion: {0}", rStatus); Console.WriteLine("Interface.MotionGetFirewareVerion: {0}", rStatus);
//Marshal.Copy(intPtrEF3Version, EF3Version, 0, EF3Version.Length); Marshal.Copy(intPtrEF3Version, EF3Version, 0, EF3Version.Length);
//Console.WriteLine("EF3 FirewareVerion Version: {0}", Encoding.UTF8.GetString(EF3Version)); Console.WriteLine("EF3 FirewareVerion Version: {0}", Encoding.UTF8.GetString(EF3Version));
#region #region
//启动扫描
Motion.DCCScanStart();
//扫描中
Thread.Sleep(10000);
//扫描结束 ////启动扫描
Motion.DCCScanStop(); //Motion.DCCScanStart();
//获取扫描结果 ////扫描中
var dataCache = Marshal.AllocHGlobal(1000); //Thread.Sleep(10000);
var pointCount = 0;
var data = new byte[1000];
Motion.GetPositionXyzCache(dataCache, ref pointCount);
Console.WriteLine("pointCount = " + pointCount);
Marshal.Copy(dataCache, data, 0, pointCount);
//打印扫描点 ////扫描结束
for (var i = 0; i < pointCount; i++) Console.WriteLine("Hex:{0} {1:X}", i, data[i]); //Motion.DCCScanStop();
////获取扫描结果
//var dataCache = Marshal.AllocHGlobal(1000);
//var pointCount = 0;
//var data = new byte[1000];
//Motion.GetPositionXyzCache(dataCache, ref pointCount);
//Console.WriteLine("pointCount = " + pointCount);
//Marshal.Copy(dataCache, data, 0, pointCount);
////打印扫描点
//for (var i = 0; i < pointCount; i++) Console.WriteLine("Hex:{0} {1:X}", i, data[i]);
#endregion #endregion
@@ -78,7 +79,7 @@ namespace HSI_SEVENOCEAN_EF1_CsTest
rStatus = Motion.IsHomed(ref bHomed); rStatus = Motion.IsHomed(ref bHomed);
Console.WriteLine("Motion.IsHomed:{0}", rStatus); Console.WriteLine("Motion.IsHomed:{0}", rStatus);
var bexit = false; var bexit = false;
var SpeedGear = 0.2; var SpeedGear = 0.3;
var dPos = new double[3]; var dPos = new double[3];
do do
{ {
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.