diff --git a/HSI_HexagonMI_EF3/HSI.cpp b/HSI_HexagonMI_EF3/HSI.cpp index 456bd73..f401e15 100644 --- a/HSI_HexagonMI_EF3/HSI.cpp +++ b/HSI_HexagonMI_EF3/HSI.cpp @@ -165,7 +165,6 @@ HSI_API HSI_STATUS WINAPI HSI_MOTION_STARTUP(bool bHome) { return HSI_STATUS_FAILED; } - //rStatus = g_pHSI_Motion->HomeMachine(bHome); switch (g_pHSI_Motion->m_iJoyStick) //摇杆设置 { case 0: diff --git a/HSI_HexagonMI_EF3/HSI.h b/HSI_HexagonMI_EF3/HSI.h index 95c2440..f197f61 100644 --- a/HSI_HexagonMI_EF3/HSI.h +++ b/HSI_HexagonMI_EF3/HSI.h @@ -21,7 +21,7 @@ #endif 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) /////////////////////////////////////////////////////////////////////////////// // Interface API diff --git a/HSI_HexagonMI_EF3/HSI_HexagonMI_EF3.vcxproj b/HSI_HexagonMI_EF3/HSI_HexagonMI_EF3.vcxproj index b7ec8ed..1cda703 100644 --- a/HSI_HexagonMI_EF3/HSI_HexagonMI_EF3.vcxproj +++ b/HSI_HexagonMI_EF3/HSI_HexagonMI_EF3.vcxproj @@ -70,7 +70,8 @@ C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x64;$(LocalDebuggerWorkingDirectory)\ACS;%(AdditionalLibraryDirectories) - copy "$(TargetDir)$(ProjectName).dll" "$(SolutionDir)HSI_SEVENOCEAN_EF1_CsTest\bin\Debug\HSI.dll" + 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" version.cmd diff --git a/HSI_HexagonMI_EF3/HSI_Motion.cpp b/HSI_HexagonMI_EF3/HSI_Motion.cpp index 64c5fdd..dea9ad6 100644 --- a/HSI_HexagonMI_EF3/HSI_Motion.cpp +++ b/HSI_HexagonMI_EF3/HSI_Motion.cpp @@ -67,7 +67,7 @@ int HSI_Motion::m_ThreadTCP_State = TCPIP_THREAD_PAUSED; SOCKET m_socket[4] = {0}; -void ErrorsHandler() + void HSI_Motion::ErrorsHandler() { if (handleACS != ACSC_INVALID) { @@ -85,6 +85,15 @@ void ErrorsHandler() ErrorStr[Received] = '\0'; printf("Motion Error: %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 @@ -245,7 +254,7 @@ HSI_Motion::HSI_Motion() 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++) { 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"); return HSI_STATUS_NORMAL; } - if (m_IsUseEF3 == 0) + if (m_IsUseEF3 == 0) //不启用EF3的情况 { 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"); CurrentHomeMachineState = E_EF3_HOME_NONE; bHomed = false; + + //如果各个轴标志位 未回过家,需要回家 + rStatus = g_pHSI_Motion->HomeMachine(TRUE); //执行回家 } 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) { 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); axis_start = 0; @@ -3577,18 +3589,16 @@ HSI_STATUS HSI_Motion::SetPositionXyz(UINT AxisTypes, double PositionX, double P m_PosThread[4] = m_PositionA; //打印当前位置,目标位置 - /* g_pLogger->SendAndFlushWithTime( - L"[SetPositionXyzNowPos] Pos[1] = %.4f,Pos[2] = %.4f,Pos[3] = %.4f,Pos[4] = %.4f, Resolution[1] = %.4f\n", + g_pLogger->SendAndFlushWithTime( + 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[4] * m_Resolution[4], m_Resolution[1]); - g_pLogger->SendAndFlushWithTime( - L"[SetPositionXyzTagPos] Pos[1] = %.4f, Pos[2] = %.4f, Pos[3] = %.4f\n", PositionX, - PositionY, PositionZ);*/ + g_pLogger->SendAndFlushWithTime(L"[SetPositionXyz] Pos[1] = %.4f, Pos[2] = %.4f, Pos[3] = %.4f\n", PositionX,PositionY, PositionZ); //打印轴当前运动参数 byte AxisNumber = static_cast(AxisConvertIndex(AxisTypes)); //轴号换算 double motionParam[5] = {0}; - GetMotorParam(AxisNumber, motionParam); + GetMotorParam(AxisNumber, motionParam); //获取单轴运动参数 g_pLogger->SendAndFlushWithTime( 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]); @@ -3605,9 +3615,6 @@ HSI_STATUS HSI_Motion::SetPositionXyz(UINT AxisTypes, double PositionX, double P ErrorsHandler(); } - //启动插补和定位功能 - - //圆弧插补 //状态更新 if (eType == HSI_MOTION_MOVE_NOWAIT) //非等待 @@ -3676,7 +3683,7 @@ int HSI_Motion::CaculateStepMotorACC(int pos, int maxacc, int minacc) //void func0(uchar*& r); //利用引用返回数组 /** - * \brief 求各轴运动配置参数 + * \brief 获取单轴运动参数 * \param AXIS * \param motionParam * \return @@ -3688,32 +3695,35 @@ HSI_STATUS HSI_Motion::GetMotorParam(int AXIS, double motionParam[5]) { g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] In\n"); - //依次是 速度、加速度、减速、杀死速度、抖动 + //依次是 速度 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)) { g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] acsc_GetAcceleration error\n"); rStatus = HSI_ACS_ERROR; ErrorsHandler(); } + //减速、 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)) { g_pLogger->SendAndFlushWithTime(L"[GetMotorParam] acsc_GetKillDeceleration error\n"); rStatus = HSI_ACS_ERROR; ErrorsHandler(); } + //抖动 if (!acsc_GetJerk(handleACS, AXIS, motionParam + 4, nullptr)) { 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& AccCurve, int& DecCurve) { + g_pLogger->SendAndFlushWithTime(L"[SpeedPercent] AxisNum: [%d]\n", AxisNum); int MovetoSpeedGear = 0; int flag = 1; 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); if (g_pHSI_Motion) { switch (AxisNumber) { - case 1: //轴1 + case 1: // X 轴 { if (LimitPos >= m_P_Work_Limit[1]) { @@ -7866,7 +7877,7 @@ double HSI_Motion::LimitOver(UINT AxisTypes, double& LimitPos) } break; } - case 2: + case 2: //Y 轴 { if (LimitPos >= m_P_Work_Limit[2]) { @@ -7890,7 +7901,7 @@ double HSI_Motion::LimitOver(UINT AxisTypes, double& LimitPos) } break; } - case 4: + case 4: //Z轴 { if (LimitPos >= m_P_Work_Limit[4]) { diff --git a/HSI_HexagonMI_EF3/HSI_Motion.h b/HSI_HexagonMI_EF3/HSI_Motion.h index 13b9ff7..eaf0f01 100644 --- a/HSI_HexagonMI_EF3/HSI_Motion.h +++ b/HSI_HexagonMI_EF3/HSI_Motion.h @@ -644,6 +644,7 @@ public: HSI_STATUS SpecialMotorHome(short AxisNum); HSI_STATUS SpecialMotorMove(short AxisNum, double Position); + void ErrorsHandler(); private: UINT ActiveAxis; int iaxisNum; @@ -685,6 +686,6 @@ private: }; 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 diff --git a/HSI_HexagonMI_EF3/version.h b/HSI_HexagonMI_EF3/version.h index 793f7ff..3183bc3 100644 --- a/HSI_HexagonMI_EF3/version.h +++ b/HSI_HexagonMI_EF3/version.h @@ -12,5 +12,5 @@ #define HSI_VERSION_REVNUM #define HSI_VERSION_BUILD_DATE _T(__DATE__ ) #define HSI_VERSION_BUILD_TIME _T(__TIME__ ) -#define HSI_FILE_DESCRIPTION "2024.02.26 / 16:16 " -#define HSI_FILE_CSDESCRIPTION _T("2024.02.26 / 16:16 ") +#define HSI_FILE_DESCRIPTION "2024.02.27 / 16:28 " +#define HSI_FILE_CSDESCRIPTION _T("2024.02.27 / 16:28 ") diff --git a/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.dll b/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.dll index 24e38d9..e976bf5 100644 Binary files a/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.dll and b/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.dll differ diff --git a/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.pdb b/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.pdb index 7988b88..f2e708b 100644 Binary files a/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.pdb and b/HSI_HexagonMI_EF3/x64/Debug/HSI_HexagonMI_EF3.pdb differ diff --git a/HSI_SEVENOCEAN_EF1_CsTest/HSI/HSI.cs b/HSI_SEVENOCEAN_EF1_CsTest/HSI/HSI.cs index 0fb00cf..25390d7 100644 --- a/HSI_SEVENOCEAN_EF1_CsTest/HSI/HSI.cs +++ b/HSI_SEVENOCEAN_EF1_CsTest/HSI/HSI.cs @@ -63,7 +63,9 @@ namespace HSI_SEVENOCEAN_EF1_CsTest.HSI { case HSI_EVENT_TYPE.HSI_EVENT_NONE: 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; case HSI_EVENT_TYPE.HSI_EVENT_FUNCTION: var eventFunctionId = (HSI_EVENT_FUNCTION_ID)eventId; diff --git a/HSI_SEVENOCEAN_EF1_CsTest/Program.cs b/HSI_SEVENOCEAN_EF1_CsTest/Program.cs index 2cf12d7..211f1fb 100644 --- a/HSI_SEVENOCEAN_EF1_CsTest/Program.cs +++ b/HSI_SEVENOCEAN_EF1_CsTest/Program.cs @@ -43,33 +43,34 @@ namespace HSI_SEVENOCEAN_EF1_CsTest Console.WriteLine("Motion.Startup:{0}", rStatus); //5 鑾峰彇EF3鍥轰欢鐗堟湰鍙,寰呮祴璇 - //var EF3Version = new byte[20]; - //IntPtr intPtrEF3Version = Marshal.StringToHGlobalAnsi(""); - //rStatus = Interface.MotionGetFirewareVerion(intPtrEF3Version); - //Console.WriteLine("Interface.MotionGetFirewareVerion: {0}", rStatus); - //Marshal.Copy(intPtrEF3Version, EF3Version, 0, EF3Version.Length); - //Console.WriteLine("EF3 FirewareVerion Version: {0}", Encoding.UTF8.GetString(EF3Version)); + var EF3Version = new byte[20]; + IntPtr intPtrEF3Version = Marshal.StringToHGlobalAnsi(""); + rStatus = Interface.MotionGetFirewareVerion(intPtrEF3Version); + Console.WriteLine("Interface.MotionGetFirewareVerion: {0}", rStatus); + Marshal.Copy(intPtrEF3Version, EF3Version, 0, EF3Version.Length); + Console.WriteLine("EF3 FirewareVerion Version: {0}", Encoding.UTF8.GetString(EF3Version)); #region 鎵弿鍔熻兘娴嬭瘯 - //鍚姩鎵弿 - Motion.DCCScanStart(); - - //鎵弿涓 - Thread.Sleep(10000); - //鎵弿缁撴潫 - Motion.DCCScanStop(); + ////鍚姩鎵弿 + //Motion.DCCScanStart(); - //鑾峰彇鎵弿缁撴灉 - 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); + ////鎵弿涓 + //Thread.Sleep(10000); - //鎵撳嵃鎵弿鐐 - 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 @@ -78,7 +79,7 @@ namespace HSI_SEVENOCEAN_EF1_CsTest rStatus = Motion.IsHomed(ref bHomed); Console.WriteLine("Motion.IsHomed:{0}", rStatus); var bexit = false; - var SpeedGear = 0.2; + var SpeedGear = 0.3; var dPos = new double[3]; do { diff --git a/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/Config/EF3_Config.ini b/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/Config/EF3_Config.ini index 7ccb5bd..7bce798 100644 Binary files a/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/Config/EF3_Config.ini and b/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/Config/EF3_Config.ini differ diff --git a/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI.dll b/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI.dll index 24e38d9..e976bf5 100644 Binary files a/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI.dll and b/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI.dll differ diff --git a/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.exe b/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.exe index 33233c6..cc4d063 100644 Binary files a/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.exe and b/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.exe differ diff --git a/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.pdb b/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.pdb index f31fb13..8ede891 100644 Binary files a/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.pdb and b/HSI_SEVENOCEAN_EF1_CsTest/bin/Debug/HSI_SEVENOCEAN_EF1_CsTest.pdb differ diff --git a/SerialAssistant/WPFSerialAssistant.zip b/SerialAssistant/WPFSerialAssistant.zip deleted file mode 100644 index e7831f8..0000000 Binary files a/SerialAssistant/WPFSerialAssistant.zip and /dev/null differ diff --git a/x64/Debug/ACSPL_VS2017.exe b/x64/Debug/ACSPL_VS2017.exe deleted file mode 100644 index 21e9b76..0000000 Binary files a/x64/Debug/ACSPL_VS2017.exe and /dev/null differ diff --git a/x64/Debug/ACSPL_VS2017.ilk b/x64/Debug/ACSPL_VS2017.ilk deleted file mode 100644 index 74943f5..0000000 Binary files a/x64/Debug/ACSPL_VS2017.ilk and /dev/null differ diff --git a/x64/Debug/ACSPL_VS2017.pdb b/x64/Debug/ACSPL_VS2017.pdb deleted file mode 100644 index 3638af3..0000000 Binary files a/x64/Debug/ACSPL_VS2017.pdb and /dev/null differ diff --git a/x64/Debug/HSI_Sevenocean_EF1.dll b/x64/Debug/HSI_Sevenocean_EF1.dll deleted file mode 100644 index b7d42c7..0000000 Binary files a/x64/Debug/HSI_Sevenocean_EF1.dll and /dev/null differ diff --git a/x64/Debug/HSI_Sevenocean_EF1.exp b/x64/Debug/HSI_Sevenocean_EF1.exp deleted file mode 100644 index 6ffb170..0000000 Binary files a/x64/Debug/HSI_Sevenocean_EF1.exp and /dev/null differ diff --git a/x64/Debug/HSI_Sevenocean_EF1.ilk b/x64/Debug/HSI_Sevenocean_EF1.ilk deleted file mode 100644 index cd17b7b..0000000 Binary files a/x64/Debug/HSI_Sevenocean_EF1.ilk and /dev/null differ diff --git a/x64/Debug/HSI_Sevenocean_EF1.lib b/x64/Debug/HSI_Sevenocean_EF1.lib deleted file mode 100644 index feb3ee9..0000000 Binary files a/x64/Debug/HSI_Sevenocean_EF1.lib and /dev/null differ diff --git a/x64/Debug/HSI_Sevenocean_EF1.pdb b/x64/Debug/HSI_Sevenocean_EF1.pdb deleted file mode 100644 index e312789..0000000 Binary files a/x64/Debug/HSI_Sevenocean_EF1.pdb and /dev/null differ