新增 dll 通过串口获取 EF3固件版本号
This commit is contained in:
@@ -119,7 +119,6 @@ Global
|
||||
{26BA6D1A-E94D-46EE-A361-2D1AFDB2338A}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{26BA6D1A-E94D-46EE-A361-2D1AFDB2338A}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{26BA6D1A-E94D-46EE-A361-2D1AFDB2338A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{26BA6D1A-E94D-46EE-A361-2D1AFDB2338A}.Debug|x64.Build.0 = Debug|x64
|
||||
{26BA6D1A-E94D-46EE-A361-2D1AFDB2338A}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{26BA6D1A-E94D-46EE-A361-2D1AFDB2338A}.Debug|x86.Build.0 = Debug|Win32
|
||||
{26BA6D1A-E94D-46EE-A361-2D1AFDB2338A}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#endif
|
||||
|
||||
const int HSI_APIVersionMajor = 0;
|
||||
const int HSI_APIVersionMinor = 1;
|
||||
const int HSI_APIVersionMinor = 0;
|
||||
|
||||
const int HSI_MaxStringLength = 255; // Maximum string length (buffer size - 1)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -64,6 +64,15 @@ 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();
|
||||
};
|
||||
|
||||
|
||||
HSI_Motion::HSI_Motion()
|
||||
{
|
||||
TRACE0("HSI_Motion Constructor!\n");
|
||||
@@ -97,6 +106,7 @@ HSI_Motion::HSI_Motion()
|
||||
m_IsUseSixRingEightArea = 0; //是否启用六环八区灯功能 0为不启用 1为启用 2为二环八区灯 默认为0
|
||||
m_IsUseTwentySixLight = 0; //是否启用26路灯光 0为不启用 1位启用 默认为0
|
||||
m_IsUseEF3 = 0; //是否启用EF3
|
||||
m_IsUseACS = 0; //是否启用ACS
|
||||
m_IsUseRocker = 0; //是否启用摇杆 0为不启用 1为启用旧摇杆,2为新摇杆, 默认为0
|
||||
m_IsCloseRocker = 0;
|
||||
m_DeviceType = 0; //设备类型,0为通用设备,1为三激光, 2为大视野,3为转盘设备 默认为0
|
||||
@@ -264,6 +274,7 @@ HSI_Motion::HSI_Motion()
|
||||
m_cSendData[4] = 4;
|
||||
m_cSendData[6] = 4;
|
||||
m_bConnected = false;
|
||||
m_bACSConnected = false; //初始化,默认打开失败
|
||||
|
||||
first = true;
|
||||
LightSend = 0;
|
||||
@@ -370,6 +381,7 @@ HSI_STATUS HSI_Motion::Startup(HWND _hWnd, bool _bOfflineOnly)
|
||||
Load_EF3_Config_Inifile(GoogolMotionConfigFile); //加载 EF3_Config.ini 配置项
|
||||
GoogolMotionConfigFile = m_AppPath + _T("\\Config\\EF3_Motion.ini");
|
||||
Load_EF3_Motion_Inifile(GoogolMotionConfigFile); // 加载 EF3_Motion.ini 配置项
|
||||
|
||||
if (m_IsUseEF3 == 1) //如果使用 EF3
|
||||
{
|
||||
if (!m_bConnected)
|
||||
@@ -389,12 +401,50 @@ HSI_STATUS HSI_Motion::Startup(HWND _hWnd, bool _bOfflineOnly)
|
||||
}
|
||||
m_SO7_Serial.SetTimeouts(1000, 1000);
|
||||
m_bConnected = true;
|
||||
g_pLogger->SendAndFlushWithTime(L"[Startup] Serial is open success\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[Startup] Serial is opened\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (m_IsUseACS == 1) //如果启用ACS
|
||||
{
|
||||
if (!m_bACSConnected)
|
||||
{
|
||||
//尝试打开ACS控制器
|
||||
g_pLogger->SendAndFlushWithTime(L"[ACS Motion] In\n");
|
||||
g_pLogger->SendAndFlushWithTime(
|
||||
L"[ACS Motion] Wait for opening of communication with the controller... \n");
|
||||
|
||||
// 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
|
||||
// hComm = acsc_OpenCommEthernet("10.0.0.100", ACSC_SOCKET_STREAM_PORT);
|
||||
|
||||
if (handleACS == ACSC_INVALID) //打开失败
|
||||
{
|
||||
ErrorsHandler("error while opening communication.\n", FALSE);
|
||||
g_pLogger->SendAndFlushWithTime(L"[ACS Motion] error while opening communication.\n");
|
||||
sEvenProp.Init();
|
||||
sEvenProp.EventType = HSI_EVENT_ERROR;
|
||||
sEvenProp.EventID = HSI_EVENT_MOTION;
|
||||
sEvenProp.EventResponse = HSI_EVENT_RESPONSE_OK;
|
||||
strcpy_s(sEvenProp.EventData, HSI_MaxStringLength, "ACS控制器打开失败");
|
||||
EventCallback(sEvenProp);
|
||||
return HSI_STATUS_FAILED;
|
||||
}
|
||||
m_bACSConnected = true;
|
||||
g_pLogger->SendAndFlushWithTime(L"[ACS Motion] Communication with the controller established success\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pLogger->SendAndFlushWithTime(L"[ACS Motion] Communication with the controller is already established successfully!\n");
|
||||
}
|
||||
}
|
||||
|
||||
// 04 05 0F 4A 04 00 04 00 00 00 00 00 00 00 00 00
|
||||
//
|
||||
//01 01 0F 04 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
@@ -420,17 +470,17 @@ HSI_STATUS HSI_Motion::Startup(HWND _hWnd, bool _bOfflineOnly)
|
||||
//01 06 07 53 01 0F 00 00 F4 01 00 00 F4 01 00 00
|
||||
|
||||
//AbortMotion();
|
||||
m_cSendData[0] = CT_ORDER;
|
||||
m_cSendData[1] = CT_STOP;
|
||||
m_cSendData[2] = AXIS_XYZU;
|
||||
m_StopJogMode[1] == 0 ? m_cSendData[3] = 0X4A : m_cSendData[3] = 0X05;
|
||||
m_StopJogMode[2] == 0 ? m_cSendData[3] = 0X4A : m_cSendData[3] = 0X05;
|
||||
m_StopJogMode[3] == 0 ? m_cSendData[3] = 0X4A : m_cSendData[3] = 0X05;
|
||||
m_StopJogMode[4] == 0 ? m_cSendData[3] = 0X4A : m_cSendData[3] = 0X05;
|
||||
m_WriteByte = Send_Command(0, (const char*)m_cSendData, m_SendDataLength);
|
||||
Sleep(5);
|
||||
//m_cSendData[0] = CT_ORDER;//停止运动
|
||||
//m_cSendData[1] = CT_STOP;
|
||||
//m_cSendData[2] = AXIS_XYZU;
|
||||
//m_StopJogMode[1] == 0 ? m_cSendData[3] = 0X4A : m_cSendData[3] = 0X05;
|
||||
//m_StopJogMode[2] == 0 ? m_cSendData[3] = 0X4A : m_cSendData[3] = 0X05;
|
||||
//m_StopJogMode[3] == 0 ? m_cSendData[3] = 0X4A : m_cSendData[3] = 0X05;
|
||||
//m_StopJogMode[4] == 0 ? m_cSendData[3] = 0X4A : m_cSendData[3] = 0X05;
|
||||
//m_WriteByte = Send_Command(0, (const char*)m_cSendData, m_SendDataLength);
|
||||
//Sleep(5);
|
||||
|
||||
if (m_DeviceType == 3)
|
||||
if (m_DeviceType == 3) //转盘设备,当前未使用
|
||||
{
|
||||
m_cSendData[0] = CT_TURNTABLE;
|
||||
m_cSendData[1] = CT_RTSTOP;
|
||||
@@ -439,7 +489,8 @@ HSI_STATUS HSI_Motion::Startup(HWND _hWnd, bool _bOfflineOnly)
|
||||
m_Thread_StateData = HSI_THREAD_RUNNING;
|
||||
SetEvent(m_hTriggerEventData);
|
||||
}
|
||||
if (bUseGlueDispenser)
|
||||
|
||||
if (bUseGlueDispenser) //点胶,当前未使用
|
||||
{
|
||||
bUseGlueDispenser = false;
|
||||
m_cSendData[0] = CT_MOTOR;
|
||||
@@ -455,56 +506,57 @@ HSI_STATUS HSI_Motion::Startup(HWND _hWnd, bool _bOfflineOnly)
|
||||
g_pLogger->SendAndFlushWithTime(L"[Startup] DriverAlarmStatus HSI_STATUS_FAILED\n");
|
||||
//return HSI_STATUS_FAILED;
|
||||
}
|
||||
//无效软限位
|
||||
m_cSendData[0] = CT_MOTOR;
|
||||
m_cSendData[1] = CT_MOTOR_SET;
|
||||
m_cSendData[2] = AXIS_XYZU;
|
||||
m_cSendData[3] = SOFT_LIMIT_POS_NEG;
|
||||
m_cSendData[4] = 0;
|
||||
m_cSendData[5] = 0;
|
||||
m_cSendData[6] = 0;
|
||||
m_cSendData[7] = 0;
|
||||
m_cSendData[8] = 0;
|
||||
m_cSendData[9] = 0;
|
||||
m_cSendData[10] = 0;
|
||||
m_cSendData[11] = 0;
|
||||
m_WriteByte = Send_Command(0, (const char*)m_cSendData, m_SendDataLength); //初始化防止第一次无效
|
||||
Sleep(5);
|
||||
m_WriteByte = Send_Command(0, (const char*)m_cSendData, m_SendDataLength);
|
||||
g_pLogger->SendAndFlushWithTime(L"[Startup] Limit no Enable\n");
|
||||
|
||||
//无效软限位,当前未使用
|
||||
//m_cSendData[0] = CT_MOTOR;
|
||||
//m_cSendData[1] = CT_MOTOR_SET;
|
||||
//m_cSendData[2] = AXIS_XYZU;
|
||||
//m_cSendData[3] = SOFT_LIMIT_POS_NEG;
|
||||
//m_cSendData[4] = 0;
|
||||
//m_cSendData[5] = 0;
|
||||
//m_cSendData[6] = 0;
|
||||
//m_cSendData[7] = 0;
|
||||
//m_cSendData[8] = 0;
|
||||
//m_cSendData[9] = 0;
|
||||
//m_cSendData[10] = 0;
|
||||
//m_cSendData[11] = 0;
|
||||
//m_WriteByte = Send_Command(0, (const char*)m_cSendData, m_SendDataLength); //初始化防止第一次无效
|
||||
//Sleep(5);
|
||||
//m_WriteByte = Send_Command(0, (const char*)m_cSendData, m_SendDataLength);
|
||||
//g_pLogger->SendAndFlushWithTime(L"[Startup] Limit no Enable\n");
|
||||
|
||||
//设置方向4个轴的方向,按位
|
||||
m_cSendData[0] = CT_MOTOR;
|
||||
m_cSendData[1] = CT_MOTOR_SET;
|
||||
m_cSendData[2] = AXIS_X;
|
||||
m_cSendData[3] = ENC_POS_DIR;
|
||||
m_cSendData[4] = m_Set_XYZA_Reserve;
|
||||
m_cSendData[5] = m_setPositionDelay;
|
||||
m_cSendData[6] = m_setPositionPrecision;
|
||||
m_WriteByte = Send_Command(0, (const char*)m_cSendData, m_SendDataLength);
|
||||
Sleep(10);
|
||||
m_cSendData[0] = CT_MOTOR;
|
||||
m_cSendData[1] = CT_MDATA_INIT;
|
||||
m_cSendData[2] = m_motorType & 0xff; //电机类型(步进电机或伺服电机)
|
||||
m_cSendData[3] = m_IsUseExternalTrigger; //是否启用外触发功能
|
||||
m_cSendData[4] = m_IsUseSixRingEightArea; //是否启用六环八区灯功能
|
||||
m_cSendData[5] = m_IsHardLimit;
|
||||
m_cSendData[6] = m_IsEnableAxis;
|
||||
m_cSendData[7] = m_IsProbe; //是否启用探针
|
||||
m_cSendData[8] = m_EF3LightType; //5V高频灯光配置
|
||||
m_cSendData[9] = m_IsUseRocker; //是否启用摇杆
|
||||
m_cSendData[10] = m_IsHavePattern; //光栅
|
||||
m_cSendData[11] = m_AxisHomeDirection; //轴回家方向
|
||||
m_cSendData[12] = m_IsCollectPos; //是否从串口打印位置
|
||||
m_cSendData[16] = m_IsLightDebug; //是否不回家也能调试灯光
|
||||
//m_cSendData[0] = CT_MOTOR;
|
||||
//m_cSendData[1] = CT_MOTOR_SET;
|
||||
//m_cSendData[2] = AXIS_X;
|
||||
//m_cSendData[3] = ENC_POS_DIR;
|
||||
//m_cSendData[4] = m_Set_XYZA_Reserve;
|
||||
//m_cSendData[5] = m_setPositionDelay;
|
||||
//m_cSendData[6] = m_setPositionPrecision;
|
||||
//m_WriteByte = Send_Command(0, (const char*)m_cSendData, m_SendDataLength);
|
||||
//Sleep(10);
|
||||
//m_cSendData[0] = CT_MOTOR;
|
||||
//m_cSendData[1] = CT_MDATA_INIT;
|
||||
//m_cSendData[2] = m_motorType & 0xff; //电机类型(步进电机或伺服电机)
|
||||
//m_cSendData[3] = m_IsUseExternalTrigger; //是否启用外触发功能
|
||||
//m_cSendData[4] = m_IsUseSixRingEightArea; //是否启用六环八区灯功能
|
||||
//m_cSendData[5] = m_IsHardLimit;
|
||||
//m_cSendData[6] = m_IsEnableAxis;
|
||||
//m_cSendData[7] = m_IsProbe; //是否启用探针
|
||||
//m_cSendData[8] = m_EF3LightType; //5V高频灯光配置
|
||||
//m_cSendData[9] = m_IsUseRocker; //是否启用摇杆
|
||||
//m_cSendData[10] = m_IsHavePattern; //光栅
|
||||
//m_cSendData[11] = m_AxisHomeDirection; //轴回家方向
|
||||
//m_cSendData[12] = m_IsCollectPos; //是否从串口打印位置
|
||||
//m_cSendData[16] = m_IsLightDebug; //是否不回家也能调试灯光
|
||||
|
||||
if (m_IsStartInput == 1 && m_IsUseRocker == 2)
|
||||
{
|
||||
m_cSendData[14] = m_StartInputPort >> 8 & 0xff; //外部启动端口号 H
|
||||
m_cSendData[15] = m_StartInputPort & 0xff; //外部启动端口号 L
|
||||
}
|
||||
m_WriteByte = Send_Command(0, (const char*)m_cSendData, m_SendDataLength);
|
||||
Sleep(10);
|
||||
//if (m_IsStartInput == 1 && m_IsUseRocker == 2) //新摇杆,并启动脚踏功能
|
||||
//{
|
||||
// m_cSendData[14] = m_StartInputPort >> 8 & 0xff; //外部启动端口号 H
|
||||
// m_cSendData[15] = m_StartInputPort & 0xff; //外部启动端口号 L
|
||||
//}
|
||||
//m_WriteByte = Send_Command(0, (const char*)m_cSendData, m_SendDataLength);
|
||||
//Sleep(10);
|
||||
|
||||
////步进电机补偿值设定
|
||||
//if (m_motorType == 0)
|
||||
@@ -603,23 +655,24 @@ HSI_STATUS HSI_Motion::Startup(HWND _hWnd, bool _bOfflineOnly)
|
||||
g_pLogger->SendAndFlushWithTime(L"[Startup] Set Gears Success\n");
|
||||
}
|
||||
|
||||
CreateThread(); //刷新位置状态
|
||||
SetEvent(m_hTriggerEvent);
|
||||
m_Thread_State = HSI_THREAD_PAUSED;
|
||||
g_pLogger->SendAndFlushWithTime(L"[Startup] SetpositionXyz Enable\n");
|
||||
//CreateThread(); //刷新位置状态线程
|
||||
//SetEvent(m_hTriggerEvent);
|
||||
//m_Thread_State = HSI_THREAD_PAUSED;
|
||||
//g_pLogger->SendAndFlushWithTime(L"[Startup] SetpositionXyz Enable\n");
|
||||
|
||||
CreateThreadData(); //读取EF3的数据状态
|
||||
SetEvent(m_hTriggerEventData);
|
||||
m_Thread_StateData = HSI_THREAD_RUNNING;
|
||||
g_pLogger->SendAndFlushWithTime(L"[Startup] Read EF3 Status Run\n");
|
||||
//CreateThreadData(); //读取EF3数据状态线程
|
||||
//SetEvent(m_hTriggerEventData);
|
||||
//m_Thread_StateData = HSI_THREAD_RUNNING;
|
||||
//g_pLogger->SendAndFlushWithTime(L"[Startup] Read EF3 Status Run\n");
|
||||
|
||||
if (m_DeviceType != 3)
|
||||
{
|
||||
CreateThreadJOGStop(); ////JOG运行到软限位的运动调节
|
||||
SetEvent(m_hTriggerEventJOGStop);
|
||||
m_Thread_StateJOGStop = HSI_THREAD_PAUSED;
|
||||
}
|
||||
if (m_IsIOFuntion == 1) //是否启用IO功能,通过配置文件启用
|
||||
//if (m_DeviceType != 3)
|
||||
//{
|
||||
// CreateThreadJOGStop(); ////JOG运行到软限位的运动调节线程
|
||||
// SetEvent(m_hTriggerEventJOGStop);
|
||||
// m_Thread_StateJOGStop = HSI_THREAD_PAUSED;
|
||||
//}
|
||||
|
||||
if (m_IsIOFuntion == 1) //是否启用IO功能线程,通过配置文件启用
|
||||
{
|
||||
m_Thread_StateIO = HSI_THREAD_RUNNING;
|
||||
CreateThreadIO(); //IO发消息使用
|
||||
@@ -627,6 +680,7 @@ HSI_STATUS HSI_Motion::Startup(HWND _hWnd, bool _bOfflineOnly)
|
||||
g_pLogger->SendAndFlushWithTime(L"[Startup] m_IsIOFuntion Enable\n");
|
||||
SetDIO(HSI_MOTION_OUTPUT_CH1, 0xfffff);
|
||||
}
|
||||
|
||||
if (m_IsProbe == 1) //是否启用探针捕获功能,通过配置文件启用
|
||||
{
|
||||
CreateThreadProbe(); //探针捕获功能
|
||||
@@ -651,17 +705,21 @@ HSI_STATUS HSI_Motion::GetFirmwareVersion(byte* version)
|
||||
Sleep(3);
|
||||
int waite_count = 0;
|
||||
unsigned char senddata[64] = {0};
|
||||
senddata[0] = 0x04;
|
||||
senddata[1] = 0x03;
|
||||
//senddata[0] = 0x04;
|
||||
//senddata[1] = 0x03;
|
||||
|
||||
senddata[0] = 0x01;
|
||||
senddata[1] = 0x08;
|
||||
m_SO7_Serial.m_RecvData[0] = 0;
|
||||
m_WriteByte = Send_Command(0, (const char*)senddata, m_SendDataLength);
|
||||
m_WriteByte = Send_Command(0, (const char*)senddata, sizeof(senddata));
|
||||
Sleep(30);
|
||||
m_SO7_Serial.m_RecvData[0] = 0;
|
||||
m_WriteByte = Send_Command(0, (const char*)senddata, m_SendDataLength);
|
||||
m_WriteByte = Send_Command(0, (const char*)senddata, sizeof(senddata));
|
||||
Sleep(30);
|
||||
m_SO7_Serial.m_RecvData[0] = 0;
|
||||
m_WriteByte = Send_Command(0, (const char*)senddata, m_SendDataLength);
|
||||
m_WriteByte = Send_Command(0, (const char*)senddata, sizeof(senddata));
|
||||
Sleep(30);
|
||||
|
||||
while ((m_SO7_Serial.m_RecvData[0] != 3) && (m_SO7_Serial.m_RecvData[0] != 2))
|
||||
{
|
||||
waite_count++;
|
||||
@@ -672,7 +730,7 @@ HSI_STATUS HSI_Motion::GetFirmwareVersion(byte* version)
|
||||
if (waite_count > 100)
|
||||
{
|
||||
waite_count = 0;
|
||||
m_WriteByte = Send_Command(0, (const char*)senddata, m_SendDataLength);
|
||||
m_WriteByte = Send_Command(0, (const char*)senddata, sizeof(senddata));
|
||||
while ((m_SO7_Serial.m_RecvData[0] != 3) && (m_SO7_Serial.m_RecvData[0] != 2))
|
||||
{
|
||||
waite_count++;
|
||||
@@ -3107,7 +3165,7 @@ HSI_STATUS HSI_Motion::Load_EF3_Config_Inifile(CString GoogolIniFile)
|
||||
return HSI_STATUS_FAILED;
|
||||
}
|
||||
m_IsUseEF3 = GetPrivateProfileInt(L"EF3", L"IS_USEEF3", 0, csAppPath);
|
||||
|
||||
m_IsUseACS = GetPrivateProfileInt(L"EF3", L"IS_USEACS", 0, csAppPath);
|
||||
m_ForSoft = GetPrivateProfileInt(L"SOFTWARE", L"USE_SOFTWARE", 0, csAppPath);
|
||||
|
||||
m_IsUse_HSICompensation = GetPrivateProfileInt(L"ASIX", L"IS_USE_HSICOMPENSATION", 0, csAppPath);
|
||||
@@ -6884,7 +6942,6 @@ unsigned __stdcall HSI_Motion::m_ThreadSendTCP(LPVOID pThis)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TCPIP_RETURN_CODE HSI_Motion::TCPSend()
|
||||
{
|
||||
if (m_tcpCntFlag[m_selectedIndex])
|
||||
@@ -7047,7 +7104,6 @@ TCPIP_RETURN_CODE HSI_Motion::TCPSend()
|
||||
return TCPIP_CONNECT_OK;
|
||||
}
|
||||
|
||||
|
||||
void HSI_Motion::Create_Thread()
|
||||
{
|
||||
if (!m_ThreadTCP_Id)
|
||||
|
||||
@@ -355,6 +355,7 @@ public:
|
||||
int m_SixEightSubArea[8]; //六环八区分区功能
|
||||
int m_IsUseTwentySixLight; //是否启用26路灯光 0为不启用 1位启用 默认为0
|
||||
int m_IsUseEF3; //是否启用EF3
|
||||
int m_IsUseACS; //是否用ACS运动控制
|
||||
int m_DeviceType; //设备类型,0为通用设备,1为三激光, 2为大视野,3为转盘设备 默认为0
|
||||
int m_UseAxisNum; //转盘设备使用轴号
|
||||
int m_IbinCount; //记录获取到的分bin数
|
||||
@@ -444,6 +445,7 @@ public:
|
||||
double m_PrfPos[5];
|
||||
double m_PosForAllAxis[5]; //记录4轴位置
|
||||
bool m_bConnected;
|
||||
bool m_bACSConnected;// ACS是否连接成功
|
||||
int m_SendDataLength;
|
||||
unsigned char m_cSendData[64];
|
||||
unsigned char m_direct_pos;
|
||||
@@ -550,4 +552,8 @@ private:
|
||||
};
|
||||
|
||||
extern HSI_Motion* g_pHSI_Motion;
|
||||
|
||||
|
||||
extern void ErrorsHandler(const char* ErrorMessage, BOOL fCloseComm); //ACS 错误打印
|
||||
|
||||
#endif
|
||||
|
||||
@@ -175,6 +175,7 @@ DWORD CPSerial::Open()
|
||||
// Setup the port according to the stored parameters
|
||||
if (ProgramPort(m_Port, m_Baud, m_Parity, m_Bits, m_StopBits, m_HandShake))
|
||||
{
|
||||
TRACE(_T("CmmIO> Port OPEN %s\n", m_Port), Ok);
|
||||
// Setup the timeouts
|
||||
CommTimeOut.ReadIntervalTimeout = 25;
|
||||
CommTimeOut.ReadTotalTimeoutMultiplier = 1;
|
||||
|
||||
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.
@@ -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 "2022.10.12 / 9:29 "
|
||||
#define HSI_FILE_CSDESCRIPTION _T("2022.10.12 / 9:29 ")
|
||||
#define HSI_FILE_DESCRIPTION "2022.10.12 / 13:49 "
|
||||
#define HSI_FILE_CSDESCRIPTION _T("2022.10.12 / 13:49 ")
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,134 +1,150 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using HSI_SEVENOCEAN_EF1_CsTest;
|
||||
using HSI_SEVENOCEAN_EF1_CsTest.HSI;
|
||||
|
||||
namespace HSI_SEVENOCEAN_EF1_CsTest
|
||||
{
|
||||
class Program
|
||||
{
|
||||
private static Interface.PEventCallback _eventCallback;
|
||||
internal class Program
|
||||
{
|
||||
private static Interface.PEventCallback _eventCallback;
|
||||
|
||||
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
//获取HSI Dll版本
|
||||
uint major = Def.HSI_APIVersionMajor;
|
||||
uint minjor = Def.HSI_APIVersionMinor;
|
||||
var rStatus = Interface.GetInterfaceVersion(ref major, ref minjor);
|
||||
Console.WriteLine("Interface.GetInterfaceVersion: {0}", rStatus);
|
||||
Console.WriteLine("HSI.dll Version: {0}.{1}", major, minjor);
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
uint major = Def.HSI_APIVersionMajor;
|
||||
uint minjor = Def.HSI_APIVersionMinor;
|
||||
var rStatus = Interface.GetInterfaceVersion(ref major, ref minjor);
|
||||
Console.WriteLine("Interface.GetInterfaceVersion:{0}", rStatus);
|
||||
Console.WriteLine("Version:{0}.{1}", major, minjor);
|
||||
var mainIntPtr = User32Api.GetCurrentWindowHandle();
|
||||
rStatus = Interface.Startup(mainIntPtr, false);
|
||||
Console.WriteLine("Interface.Startup:{0}", rStatus);
|
||||
//HSI 初始化
|
||||
var mainIntPtr = User32Api.GetCurrentWindowHandle();
|
||||
rStatus = Interface.Startup(mainIntPtr, false);
|
||||
Console.WriteLine("Interface.Startup: {0}", rStatus);
|
||||
|
||||
Interface.HsiCallback=new Interface.PEventCallback(Interface.EventCallback);
|
||||
rStatus = Interface.SetEventCallback(Interface.HsiCallback);
|
||||
Console.WriteLine("SetEventCallback:{0}", rStatus);
|
||||
//获取机器类型
|
||||
var machineVersion = Def.HSI_EF3Version;
|
||||
rStatus = Interface.GetMachineInfo(ref machineVersion);
|
||||
Console.WriteLine("Interface.GetMachineInfo: {0}", rStatus);
|
||||
Console.WriteLine("HSI EF3 Version: {0}", machineVersion);
|
||||
|
||||
//if (Motion.IsActive(true))
|
||||
{
|
||||
rStatus = Motion.Startup(true);
|
||||
Console.WriteLine("Motion.Startup:{0}", rStatus);
|
||||
|
||||
|
||||
var bHomed = true;
|
||||
rStatus = Motion.IsHomed(ref bHomed);
|
||||
Console.WriteLine("Motion.IsHomed:{0}", rStatus);
|
||||
var bexit = false;
|
||||
double SpeedGear = 1.0;
|
||||
var dPos = new double[3];
|
||||
do
|
||||
{
|
||||
var info = Console.ReadKey();
|
||||
double dTime = 0;
|
||||
switch (info.Key)
|
||||
{
|
||||
case ConsoleKey.P:
|
||||
dPos[0] += 10.0;
|
||||
dPos[1] += 10.0;
|
||||
rStatus = Motion.SetPositionXyz(Def.HSI_MOTION_AXIS_ALL, dPos[0], dPos[1], dPos[2], Def.HSI_MOTION_MOVE_TYPE.HSI_MOTION_MOVE_NOWAIT, 0.0);
|
||||
//设置回调,方便根据回调结果进行提醒
|
||||
Interface.HsiCallback = Interface.EventCallback;
|
||||
rStatus = Interface.SetEventCallback(Interface.HsiCallback);
|
||||
Console.WriteLine("SetEventCallback:{0}", rStatus); //事件回调成功
|
||||
|
||||
break;
|
||||
case ConsoleKey.Enter:
|
||||
rStatus = Motion.GetPositionXyz(Def.HSI_MOTION_AXIS_ALL, ref dPos[0], ref dPos[1], ref dPos[2], ref dTime);
|
||||
Console.WriteLine("Motion.GetPositionXyz:{0}", rStatus);
|
||||
Console.WriteLine("Motion.XYZ:{0},{1},{2}", dPos[0], dPos[1], dPos[2]);
|
||||
break;
|
||||
case ConsoleKey.Escape:
|
||||
bexit = true;
|
||||
break;
|
||||
case ConsoleKey.Spacebar:
|
||||
rStatus = Motion.StopJog();
|
||||
Console.WriteLine("Motion.StopJog:{0}", rStatus);
|
||||
break;
|
||||
case ConsoleKey.NumPad1:
|
||||
case ConsoleKey.D1:
|
||||
SpeedGear = 1.0;
|
||||
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.NumPad2:
|
||||
case ConsoleKey.D2:
|
||||
SpeedGear = 2.0;
|
||||
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.NumPad3:
|
||||
case ConsoleKey.D3:
|
||||
SpeedGear = 3.0;
|
||||
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.NumPad4:
|
||||
case ConsoleKey.D4:
|
||||
SpeedGear = 4.0;
|
||||
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.LeftArrow:
|
||||
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_X, -SpeedGear);
|
||||
Console.WriteLine("Motion.Jog(X,{1}):{0}", rStatus, SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.RightArrow:
|
||||
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_X, SpeedGear);
|
||||
Console.WriteLine("Motion.Jog(X,{1}):{0}", rStatus, SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.DownArrow:
|
||||
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Y, -SpeedGear);
|
||||
Console.WriteLine("Motion.Jog(Y,{1}):{0}", rStatus, SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.UpArrow:
|
||||
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Y, SpeedGear);
|
||||
Console.WriteLine("Motion.Jog(Y,{1}):{0}", rStatus, SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.PageUp:
|
||||
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Z, SpeedGear);
|
||||
Console.WriteLine("Motion.Jog(Z,{1}):{0}", rStatus, SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.PageDown:
|
||||
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Z, -SpeedGear);
|
||||
Console.WriteLine("Motion.Jog(Z,{1}):{0}", rStatus, SpeedGear);
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("Invalid");
|
||||
break;
|
||||
}
|
||||
} while (!bexit);
|
||||
//if (Motion.IsActive(true))
|
||||
{
|
||||
rStatus = Motion.Startup(true); //运动初始化
|
||||
Console.WriteLine("Motion.Startup:{0}", rStatus);
|
||||
|
||||
//获取EF3固件版本号,待测试
|
||||
var EF3Version = new byte[20];
|
||||
//IntPtr intPtrEF3Version = IntPtr.Zero;
|
||||
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.Unicode.GetString(EF3Version));
|
||||
|
||||
var bHomed = true;
|
||||
rStatus = Motion.IsHomed(ref bHomed);
|
||||
Console.WriteLine("Motion.IsHomed:{0}", rStatus);
|
||||
var bexit = false;
|
||||
var SpeedGear = 1.0;
|
||||
var dPos = new double[3];
|
||||
do
|
||||
{
|
||||
var info = Console.ReadKey();
|
||||
double dTime = 0;
|
||||
switch (info.Key)
|
||||
{
|
||||
case ConsoleKey.P:
|
||||
dPos[0] += 10.0;
|
||||
dPos[1] += 10.0;
|
||||
rStatus = Motion.SetPositionXyz(Def.HSI_MOTION_AXIS_ALL, dPos[0], dPos[1], dPos[2],
|
||||
Def.HSI_MOTION_MOVE_TYPE.HSI_MOTION_MOVE_NOWAIT, 0.0);
|
||||
|
||||
break;
|
||||
case ConsoleKey.Enter:
|
||||
rStatus = Motion.GetPositionXyz(Def.HSI_MOTION_AXIS_ALL, ref dPos[0], ref dPos[1],
|
||||
ref dPos[2], ref dTime);
|
||||
Console.WriteLine("Motion.GetPositionXyz:{0}", rStatus);
|
||||
Console.WriteLine("Motion.XYZ:{0},{1},{2}", dPos[0], dPos[1], dPos[2]);
|
||||
break;
|
||||
case ConsoleKey.Escape:
|
||||
bexit = true;
|
||||
break;
|
||||
case ConsoleKey.Spacebar:
|
||||
rStatus = Motion.StopJog();
|
||||
Console.WriteLine("Motion.StopJog:{0}", rStatus);
|
||||
break;
|
||||
case ConsoleKey.NumPad1:
|
||||
case ConsoleKey.D1:
|
||||
SpeedGear = 1.0;
|
||||
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.NumPad2:
|
||||
case ConsoleKey.D2:
|
||||
SpeedGear = 2.0;
|
||||
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.NumPad3:
|
||||
case ConsoleKey.D3:
|
||||
SpeedGear = 3.0;
|
||||
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.NumPad4:
|
||||
case ConsoleKey.D4:
|
||||
SpeedGear = 4.0;
|
||||
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.LeftArrow:
|
||||
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_X, -SpeedGear);
|
||||
Console.WriteLine("Motion.Jog(X,{1}):{0}", rStatus, SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.RightArrow:
|
||||
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_X, SpeedGear);
|
||||
Console.WriteLine("Motion.Jog(X,{1}):{0}", rStatus, SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.DownArrow:
|
||||
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Y, -SpeedGear);
|
||||
Console.WriteLine("Motion.Jog(Y,{1}):{0}", rStatus, SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.UpArrow:
|
||||
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Y, SpeedGear);
|
||||
Console.WriteLine("Motion.Jog(Y,{1}):{0}", rStatus, SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.PageUp:
|
||||
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Z, SpeedGear);
|
||||
Console.WriteLine("Motion.Jog(Z,{1}):{0}", rStatus, SpeedGear);
|
||||
break;
|
||||
case ConsoleKey.PageDown:
|
||||
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Z, -SpeedGear);
|
||||
Console.WriteLine("Motion.Jog(Z,{1}):{0}", rStatus, SpeedGear);
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("Invalid");
|
||||
break;
|
||||
}
|
||||
} while (!bexit);
|
||||
|
||||
|
||||
rStatus = Motion.Shutdown();
|
||||
Console.WriteLine("Motion.Startup:{0}", rStatus);
|
||||
}
|
||||
|
||||
|
||||
rStatus = Motion.Shutdown();
|
||||
Console.WriteLine("Motion.Startup:{0}", rStatus);
|
||||
}
|
||||
rStatus = Interface.Shutdown();
|
||||
Console.WriteLine("Interface.Shutdown:{0}", rStatus);
|
||||
|
||||
|
||||
rStatus = Interface.Shutdown();
|
||||
Console.WriteLine("Interface.Shutdown:{0}", rStatus);
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Press any key to exit...");
|
||||
Console.ReadKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Press any key to exit...");
|
||||
Console.ReadKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user