250 lines
8.0 KiB
C++
250 lines
8.0 KiB
C++
// protocol for control SevenOcean's Machine
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
#ifndef AFX_ANIMATICS_Proto_H__B422904C_2CEB_495B_B7BD_B45AB30286DD__INCLUDED_
|
|
#define AFX_ANIMATICS_Proto_H__B422904C_2CEB_495B_B7BD_B45AB30286DD__INCLUDED_
|
|
|
|
#if _MSC_VER > 1000
|
|
#pragma once
|
|
#endif // _MSC_VER > 1000
|
|
|
|
#include "..\Tools\UsbUtility\logger.h"
|
|
#include "..\MicroVu\SsiStatus.h"
|
|
#include "SMIDefs.h"
|
|
//#include "IntegMotorInterface.h"
|
|
|
|
|
|
#import "IntegMotorInterface.tlb"
|
|
using namespace INTEGMOTORINTERFACELib;
|
|
|
|
#define MAX_BUFF_SIZE 0x200
|
|
|
|
#define THREAD_RUNNING_STATE 0
|
|
#define THREAD_PAUSED 1
|
|
#define THREAD_EXIT -1
|
|
#define HBIT0 0X0001
|
|
#define HBIT1 0X0002
|
|
#define HBIT2 0X0004
|
|
#define HBIT3 0X0008
|
|
#define HBIT4 0X0010
|
|
#define HBIT5 0X0020
|
|
#define HBIT6 0X0040
|
|
#define HBIT7 0X0080
|
|
#define HBIT8 0X0100
|
|
#define HBIT9 0X0200
|
|
#define HBIT10 0X0400
|
|
#define HBIT11 0X0800
|
|
#define HBIT12 0X1000
|
|
#define HBIT13 0X2000
|
|
#define HBIT14 0X4000
|
|
#define HBIT15 0X8000
|
|
|
|
|
|
#pragma pack(push)
|
|
#pragma pack(1)
|
|
//====================================================================================================
|
|
typedef struct s_smartmotor_axis // axis parameters
|
|
{
|
|
char _Move_Speed_Gear;
|
|
long _l_move_dis;
|
|
double _d_move_dis;
|
|
long _l_cur_pos;
|
|
double _d_cur_pos;
|
|
double _dSet_Zero_Pos;
|
|
long _lSet_Zero_Pos;
|
|
long address;
|
|
struct s_machine_status
|
|
{
|
|
int StatusWord[2];
|
|
|
|
BOOL DriverRdy;
|
|
BOOL MotorOff;
|
|
BOOL VoltageFault;
|
|
BOOL PosErr;
|
|
BOOL OverHeat;
|
|
BOOL NegLimit;
|
|
BOOL PosLimit;
|
|
|
|
|
|
} s_machine_status;
|
|
|
|
} SMARTMOTORAXIS;
|
|
//====================================================================================================
|
|
struct s_smartmotor_axis_config // axis configuration
|
|
{
|
|
double _motor_precision;//set precision
|
|
|
|
int _speed_[5];
|
|
int _accel_[5];
|
|
int _decel_[5];
|
|
|
|
double _neg_working_limit;
|
|
double _pos_working_limit;
|
|
|
|
double _scale_resolution;
|
|
};
|
|
//====================================================================================================
|
|
typedef struct s_smartmotor_xyzzm
|
|
{
|
|
bool bFast;
|
|
long from;
|
|
long to;
|
|
long speed;
|
|
long acc;
|
|
long dec;
|
|
double dFromMM;
|
|
double dToMM;
|
|
} SMARTMOTORAXISMOVE;
|
|
//====================================================================================================
|
|
struct struct_smartmotor_machine
|
|
{ // g_machine structure
|
|
struct s_machine_config
|
|
{
|
|
struct s_smartmotor_axis_config x_axis;
|
|
struct s_smartmotor_axis_config y_axis;
|
|
struct s_smartmotor_axis_config z_axis;
|
|
|
|
} s_machine_config;
|
|
struct s_status {
|
|
BOOL _bXHomed;
|
|
BOOL _bYHomed;
|
|
BOOL _bZHomed;
|
|
BOOL _bXYZHomed;
|
|
|
|
BOOL _machine_running;
|
|
BOOL _bXMoving;
|
|
BOOL _bYMoving;
|
|
BOOL _bZMoving;
|
|
BOOL _bXYZMoving;
|
|
} s_status;
|
|
|
|
struct s_smartmotor_axis x;
|
|
struct s_smartmotor_axis y;
|
|
struct s_smartmotor_axis z;
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
//====================================================================================================
|
|
class SmartMotor_Proto
|
|
{
|
|
public:
|
|
//=============Smart Motor===================
|
|
//ISMICommPtr CommInterface;
|
|
//ISMICMotionPtr CMotionInterface;
|
|
//ISMIPathPtr PathInterface;
|
|
|
|
ISMICommPtr CommInterface;
|
|
ISMICMotionPtr CMotionInterface;
|
|
ISMIPathPtr PathInterface;
|
|
|
|
// machine threads.
|
|
static int g_machine_Thread_State;
|
|
static unsigned __stdcall g_machine_Thread(LPVOID pThis);
|
|
static HANDLE g_machine_Thread_Id;
|
|
static HANDLE g_machine_Serial_Mutex; // EP02
|
|
|
|
static HANDLE g_hHomedEvent;
|
|
|
|
//
|
|
SmartMotor_Proto();
|
|
virtual ~SmartMotor_Proto();
|
|
|
|
// Global Structures
|
|
static struct_smartmotor_machine g_machine;
|
|
|
|
static double TimeInSecs(void);
|
|
static CLogger* g_pLogger;
|
|
|
|
bool m_bHomingActive;
|
|
|
|
double ScaleToMM(long lCount, double dResolution);
|
|
long MMtoScale(double lDistanceMM, double dResolution);
|
|
static void _swap_byte(unsigned short &Val);
|
|
static void _reverse_dword(DWORD *);
|
|
static void _scale2inch(unsigned long scale, double &inch);
|
|
static void _inch2scale(unsigned long &scale, double inch);
|
|
static long _4char2long(unsigned char *cBuff);
|
|
static long _3char2long(unsigned char *cBuff);
|
|
static void _char2bin(unsigned char *cBuff, BYTE *cBytes, int len);
|
|
|
|
SSI_STATUS_SMARTMOTOR Create_thread();
|
|
SSI_STATUS_SMARTMOTOR Exit_thread();
|
|
|
|
|
|
|
|
SSI_STATUS_SMARTMOTOR GetAppPath(CString &Path);
|
|
SSI_STATUS_SMARTMOTOR ExtractAppPath(CString &Path);
|
|
SSI_STATUS_SMARTMOTOR SaveSmartMotorConfig();
|
|
SSI_STATUS_SMARTMOTOR LoadSmartMotorConfig();
|
|
|
|
BOOL InitSmartMotor();
|
|
void StartSmartMotor();
|
|
void StopSmartMotor();
|
|
void _reset_config_parameter();
|
|
|
|
|
|
SSI_STATUS_SMARTMOTOR smartmotor_motion_startup(double x_scale_resolution, double y_scale_resolution, double z_scale_resolution);
|
|
SSI_STATUS_SMARTMOTOR smartmotor_motion_Dcc_Home();
|
|
SSI_STATUS_SMARTMOTOR smartmotor_motion_IS_Homed();
|
|
|
|
SSI_STATUS_SMARTMOTOR _start_machine();
|
|
SSI_STATUS_SMARTMOTOR _shutdown_machine();
|
|
|
|
SSI_STATUS_SMARTMOTOR smartmotor_motion_get_position_xyz(double & dX, double & dY, double & dZ);
|
|
SSI_STATUS_SMARTMOTOR smartmotor_motion_get_pos_pulse_xyz(long & lX, long & lY, long & lZ);
|
|
SSI_STATUS_SMARTMOTOR smartmotor_motion_set_position_xyz(double dX, double dY, double dZ, bool bWait);
|
|
SSI_STATUS_SMARTMOTOR smartmotor_motion_move_rel_dis_xyz(double dX, double dY, double dZ, bool bWait);
|
|
SSI_STATUS_SMARTMOTOR smartmotor_motion_stop_xyz();
|
|
SSI_STATUS_SMARTMOTOR smartmotor_motion_stop_xyz_S();
|
|
|
|
SSI_STATUS_SMARTMOTOR smartmotor_motion_get_home_status();
|
|
SSI_STATUS_SMARTMOTOR smartmotor_motion_get_motion_status();
|
|
SSI_STATUS_SMARTMOTOR smartmotor_motion_get_status_word();
|
|
|
|
SSI_STATUS_SMARTMOTOR _calculate_straightline_motion(double dSpeedMM);
|
|
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_GET_POS_XYZ();
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_MOVETOX_ABS(double dis);
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_MOVETOY_ABS(double dis);
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_MOVETOZ_ABS(double dis);
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_MOVETOX_REL(double dis);
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_MOVETOY_REL(double dis);
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_MOVETOZ_REL(double dis);
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_MOVEX(BOOL dir);
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_MOVEY(BOOL dir);
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_MOVEZ(BOOL dir);
|
|
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_ABRUPT_STOPX();
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_ABRUPT_STOPY();
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_ABRUPT_STOPZ();
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_DECEL_STOPX();
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_DECEL_STOPY();
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_DECEL_STOPZ();
|
|
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_COMM_CMDX(CString _command);
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_COMM_CMDY(CString _command);
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_COMM_CMDZ(CString _command);
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_GET_COMM_RESPONSEX(CString &_response);
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_GET_COMM_RESPONSEY(CString &_response);
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_GET_COMM_RESPONSEZ(CString &_response);
|
|
|
|
|
|
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_GET_MOVE_STATUS_X();
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_GET_MOVE_STATUS_Y();
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_GET_MOVE_STATUS_Z();
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_GET_HOME_STATUS_X();
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_GET_HOME_STATUS_Y();
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_GET_HOME_STATUS_Z();
|
|
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_GET_STATUS_WORD0();
|
|
SSI_STATUS_SMARTMOTOR _send_cmd_SMARTMOTOR_GET_STATUS_WORD16();
|
|
|
|
static SSI_STATUS_SMARTMOTOR _process_SO7_CMD_MOVE_TO_POS_XYZ();
|
|
|
|
|
|
};
|
|
|
|
#endif
|