247 lines
7.3 KiB
C++
247 lines
7.3 KiB
C++
// TestDll.cpp : 定义控制台应用程序的入口点。
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include <conio.h>
|
|
#include "..\MachineInterfaceDll\MachineInterfaceDll.h"
|
|
void ShowMessage(SSI_STATUS_MOTION status);
|
|
|
|
int _tmain(int argc, _TCHAR* argv[])
|
|
{
|
|
SSI_STATUS_MOTION status=Machine_Startup(false,HOME_NONE);
|
|
printf("Machine_Startup:");
|
|
ShowMessage(status);
|
|
printf("Test Module[1-4]:");
|
|
printf("\n");
|
|
printf("1. Motion\n");
|
|
printf("2. Illumination\n");
|
|
printf("3. IO\n");
|
|
printf("4. ALL\n");
|
|
LONG TestModule(0);
|
|
printf("Please Select Test Module[1-4]:");
|
|
scanf_s("%d", &TestModule);
|
|
|
|
//=================================================================================
|
|
//===============================Motion============================================
|
|
if (TestModule==1 || TestModule==4)
|
|
{
|
|
bool bHomed(false);
|
|
status=Motion_IsHomedXYZ(bHomed);
|
|
printf("Motion_IsHomedXYZ:");
|
|
ShowMessage(status);
|
|
if (!bHomed)
|
|
{
|
|
status=Motion_DCCHomeXYZ(HOME_XYZ);
|
|
printf("Motion_IsHomedXYZ:");
|
|
ShowMessage(status);
|
|
do
|
|
{
|
|
Sleep(20);
|
|
status=Motion_IsHomedXYZ(bHomed);
|
|
printf("Motion_IsHomedXYZ:");
|
|
ShowMessage(status);
|
|
} while (!bHomed);
|
|
}
|
|
status=Motion_Jog(MACHINE_AXIS_X,4);
|
|
printf("Motion_Jog:");
|
|
ShowMessage(status);
|
|
printf("Press any key to stop...\r\n");
|
|
_getch();
|
|
status=Motion_Stop();
|
|
printf("Motion_Stop:");
|
|
ShowMessage(status);
|
|
|
|
status=Motion_Jog(MACHINE_AXIS_Y,4);
|
|
printf("Motion_Jog:");
|
|
ShowMessage(status);
|
|
printf("Press any key to stop...\r\n");
|
|
_getch();
|
|
status=Motion_Stop();
|
|
printf("Motion_Stop:");
|
|
ShowMessage(status);
|
|
|
|
status=Motion_Jog(MACHINE_AXIS_Z,-3);
|
|
printf("Motion_Jog:");
|
|
ShowMessage(status);
|
|
Sleep(3000);
|
|
status=Motion_Stop();
|
|
printf("Motion_Stop:");
|
|
ShowMessage(status);
|
|
|
|
double PositionX,PositionY,PositionZ;
|
|
status=Motion_GetPositionXYZ(PositionX,PositionY,PositionZ);
|
|
printf("Motion_GetPositionXYZ:%.4f,%.4f.%.4f;\r\n",PositionX,PositionY,PositionZ);
|
|
int iMoveTo(0);
|
|
do
|
|
{
|
|
printf("Please input X MoveToPos:");
|
|
scanf_s("%f", &PositionX);
|
|
printf("Please input Y MoveToPos:");
|
|
scanf_s("%d", &PositionY);
|
|
printf("Please input Z MoveToPos:");
|
|
scanf_s("%d", &PositionZ);
|
|
|
|
printf("Motion_SetPositionXYZ:%.4f,%.4f.%.4f;\r\n",PositionX,PositionY,PositionZ);
|
|
status=Motion_SetPositionXYZ(PositionX,PositionY,PositionZ,true);
|
|
|
|
status=Motion_GetPositionXYZ(PositionX,PositionY,PositionZ);
|
|
printf("Motion_GetPositionXYZ:%.4f,%.4f.%.4f;\r\n",PositionY,PositionX,PositionZ);
|
|
|
|
|
|
printf("Test again?Y:1;N:0");
|
|
scanf_s("%d", &iMoveTo);
|
|
} while (iMoveTo>=1);
|
|
/*
|
|
status=Motion_SetSpeedXYZ(MACHINE_AXIS_X,3,20,20,20,3,0.01);
|
|
printf("Motion_SetSpeedXYZ:");
|
|
ShowMessage(status);
|
|
status=Motion_Jog(MACHINE_AXIS_X,3);
|
|
printf("Motion_Jog:");
|
|
ShowMessage(status);
|
|
Sleep(3000);
|
|
status=Motion_Stop();
|
|
printf("Motion_Stop:");
|
|
ShowMessage(status);
|
|
*/
|
|
//===================================Rotary Table==================================
|
|
//Motion_DCCHomeR();
|
|
//Motion_IsHomedR(bool &bHomed);
|
|
////Units:Rad
|
|
//Motion_GetPositionR(double& dPos);
|
|
//Motion_SetPositionR(double dAbsolutePos,bool bWait);
|
|
//Motion_IsFinishedR(bool &bFinished);
|
|
}
|
|
if (TestModule==2 || TestModule==4)
|
|
{
|
|
//==============================Illumination=======================================
|
|
//Range value:0.0-100.0
|
|
status=Illumination_SetLampState(0,100,0,0,0,0,0);
|
|
printf("Illumination_SetLampState:");
|
|
ShowMessage(status);
|
|
Sleep(1000);
|
|
status=Illumination_SetLampState(100,0,0,0,0,0,0);
|
|
printf("Illumination_SetLampState:");
|
|
ShowMessage(status);
|
|
Sleep(1000);
|
|
status=Illumination_SetLampState(100,100,0,0,0,0,0);
|
|
printf("Illumination_SetLampState:");
|
|
ShowMessage(status);
|
|
Sleep(1000);
|
|
}
|
|
//==============================IO================================================
|
|
if (TestModule==3 || TestModule==4)
|
|
{
|
|
BYTE bDISts(0);
|
|
bDISts=0;
|
|
status=Machine_GetDIO(INPORT_J2,bDISts);
|
|
printf("Machine_GetDIO:[INPORT_J2] 0X%02X.--",bDISts);
|
|
ShowMessage(status);
|
|
|
|
bDISts=0;
|
|
status=Machine_GetDIO(LIMIT_SWITCH_J4,bDISts);
|
|
printf("Machine_GetDIO:[LIMIT_SWITCH_J4] 0X%02X.--",bDISts);
|
|
ShowMessage(status);
|
|
printf("Get limit switch status again. Press any key...\r\n");
|
|
_getch();
|
|
bDISts=0;
|
|
status=Machine_GetDIO(LIMIT_SWITCH_J4,bDISts);
|
|
printf("Machine_GetDIO:[LIMIT_SWITCH_J4] 0X%02X.--",bDISts);
|
|
ShowMessage(status);
|
|
|
|
bDISts=0;
|
|
status=Machine_SetDO(OUTPORT_J1,bDISts);
|
|
printf("Machine_SetDO:[OUTPORT_J1] 0X00.--");
|
|
ShowMessage(status);
|
|
bDISts=0;
|
|
status=Machine_GetDIO(OUTPORT_J1,bDISts);
|
|
printf("Machine_GetDIO:[OUTPORT_J1] 0X%02X.--",bDISts);
|
|
ShowMessage(status);
|
|
bDISts=255;
|
|
status=Machine_SetDO(OUTPORT_J1,bDISts);
|
|
printf("Machine_SetDO:[OUTPORT_J1] 0XFF.--");
|
|
ShowMessage(status);
|
|
bDISts=0;
|
|
status=Machine_GetDIO(OUTPORT_J1,bDISts);
|
|
printf("Machine_GetDIO:[OUTPORT_J1] 0X%02X.--",bDISts);
|
|
ShowMessage(status);
|
|
|
|
|
|
bDISts=0;
|
|
status=Machine_SetDO(OUTPORT_J3,bDISts);
|
|
printf("Machine_SetDO:[OUTPORT_J3] 0X00.--");
|
|
ShowMessage(status);
|
|
bDISts=0;
|
|
status=Machine_GetDIO(OUTPORT_J3,bDISts);
|
|
printf("Machine_GetDIO:[OUTPORT_J3] 0X%02X.--",bDISts);
|
|
ShowMessage(status);
|
|
bDISts=255;
|
|
status=Machine_SetDO(OUTPORT_J3,bDISts);
|
|
printf("Machine_SetDO:[OUTPORT_J3] 0XFF.--");
|
|
ShowMessage(status);
|
|
bDISts=0;
|
|
status=Machine_GetDIO(OUTPORT_J3,bDISts);
|
|
printf("Machine_GetDIO:[OUTPORT_J3] 0X%02X.--",bDISts);
|
|
ShowMessage(status);
|
|
}
|
|
//==============================CMD================================================
|
|
//SEND_SYS_COMMAND(char Cmd,char SubCmd,char Type,char Data);
|
|
status=Machine_Shutdown();
|
|
printf("Machine_Shutdown:");
|
|
ShowMessage(status);
|
|
printf("Press any key to exit\r\n");
|
|
_getch();
|
|
return 0;
|
|
}
|
|
void ShowMessage(SSI_STATUS_MOTION status)
|
|
{
|
|
switch(status)
|
|
{
|
|
case SSI_STATUS_MOTION_NORMAL:
|
|
{
|
|
printf("SSI_STATUS_MOTION_NORMAL.\r\n");
|
|
break;
|
|
}
|
|
case SSI_STATUS_MOTION_DATALINK_ERROR:
|
|
{
|
|
printf("SSI_STATUS_MOTION_DATALINK_ERROR.\r\n");
|
|
break;
|
|
}
|
|
case SSI_STATUS_MOTION_LIMIT_REACHED:
|
|
{
|
|
printf("SSI_STATUS_MOTION_LIMIT_REACHED.\r\n");
|
|
break;
|
|
}
|
|
case SSI_STATUS_MOTION_INVALID_PARAMETERS:
|
|
{
|
|
printf("SSI_STATUS_MOTION_INVALID_PARAMETERS.\r\n");
|
|
break;
|
|
}
|
|
case SSI_STATUS_MOTION_TIMEOUT:
|
|
{
|
|
printf("SSI_STATUS_MOTION_TIMEOUT.\r\n");
|
|
break;
|
|
}
|
|
case SSI_STATUS_SO7_CONFIG_FILE_NOT_FOUND:
|
|
{
|
|
printf("SSI_STATUS_SO7_CONFIG_FILE_NOT_FOUND.\r\n");
|
|
break;
|
|
}
|
|
case SSI_STATUS_MOTOR_DAT_FILE_NOT_FOUND:
|
|
{
|
|
printf("SSI_STATUS_MOTOR_DAT_FILE_NOT_FOUND.\r\n");
|
|
break;
|
|
}
|
|
case SSI_STATUS_MACHINE_UNINITIALIZED:
|
|
{
|
|
printf("SSI_STATUS_MACHINE_UNINITIALIZED.\r\n");
|
|
break;
|
|
}
|
|
case SSI_STATUS_UNKNOWN_ERROR:
|
|
{
|
|
printf("SSI_STATUS_UNKNOWN_ERROR.\r\n");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|