📄 loadmpc2810.cpp
字号:
// LoadMpc2810.cpp: implementation of the CLoadMpc08ADll class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "LoadMpc2810.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CLoadMpc2810::CLoadMpc2810()
{
LoadDllFun(); //加载DLL
}
CLoadMpc2810::~CLoadMpc2810()
{
if (hDLL != NULL)
{
FreeLibrary(hDLL); //释放DLL
}
}
int CLoadMpc2810::LoadDllFun()
{
hDLL = LoadLibrary("MPC2810");
if (hDLL != NULL)
{
///////////////////////////////////////////////////////////
//以下取得各个DLL函数指针
auto_set = (LPFNDLL2810_auto_set)GetProcAddress(hDLL,"auto_set");
init_board = (LPFNDLL2810_init_board)GetProcAddress(hDLL,"init_board");
set_unit_flag = (LPFNDLL2810_set_unit_flag)GetProcAddress(hDLL,"set_unit_flag");
set_outmode = (LPFNDLL2810_set_outmode)GetProcAddress(hDLL,"set_outmode");
set_home_mode = (LPFNDLL2810_set_home_mode)GetProcAddress(hDLL,"set_home_mode");
set_dir = (LPFNDLL2810_set_dir)GetProcAddress(hDLL,"set_dir");
enable_sd = (LPFNDLL2810_enable_sd)GetProcAddress(hDLL,"enable_sd");
enable_el = (LPFNDLL2810_enable_el)GetProcAddress(hDLL,"enable_el");
enable_org = (LPFNDLL2810_enable_org)GetProcAddress(hDLL,"enable_org");
enable_alm = (LPFNDLL2810_enable_alm)GetProcAddress(hDLL,"enable_alm");
set_sd_logic = (LPFNDLL2810_set_sd_logic)GetProcAddress(hDLL,"set_sd_logic");
set_el_logic = (LPFNDLL2810_set_el_logic)GetProcAddress(hDLL,"set_el_logic");
set_org_logic = (LPFNDLL2810_set_org_logic)GetProcAddress(hDLL,"set_org_logic");
set_alm_logic = (LPFNDLL2810_set_alm_logic)GetProcAddress(hDLL,"set_alm_logic");
set_getpos_mode = (LPFNDLL2810_set_getpos_mode)GetProcAddress(hDLL,"set_getpos_mode");
set_encoder_mode = (LPFNDLL2810_set_encoder_mode)GetProcAddress(hDLL,"set_encoder_mode");
open_list = (LPFNDLL2810_open_list)GetProcAddress(hDLL,"open_list");
close_list = (LPFNDLL2810_close_list)GetProcAddress(hDLL,"close_list");
add_list = (LPFNDLL2810_add_list)GetProcAddress(hDLL,"add_list");
start_lookahead = (LPFNDLL2810_start_lookahead)GetProcAddress(hDLL,"start_lookahead");
end_lookahead = (LPFNDLL2810_end_lookahead)GetProcAddress(hDLL,"end_lookahead");
//参数设置函数
set_maxspeed = (LPFNDLL2810_set_maxspeed)GetProcAddress(hDLL,"set_maxspeed");
set_conspeed = (LPFNDLL2810_set_conspeed)GetProcAddress(hDLL,"set_conspeed");
set_vector_conspeed = (LPFNDLL2810_set_vector_conspeed)GetProcAddress(hDLL,"set_vector_conspeed");
set_profile = (LPFNDLL2810_set_profile)GetProcAddress(hDLL,"set_profile");
set_vector_profile = (LPFNDLL2810_set_vector_profile)GetProcAddress(hDLL,"set_vector_profile");
c_set_vector_profile = (LPFNDLL2810_c_set_vector_profile)GetProcAddress(hDLL,"c_set_vector_profile");
c_set_max_accel = (LPFNDLL2810_c_set_max_accel)GetProcAddress(hDLL,"c_set_max_accel");
c_set_multiple = (LPFNDLL2810_c_set_multiple)GetProcAddress(hDLL,"c_set_multiple");
set_ellipse_ratio = (LPFNDLL2810_set_ellipse_ratio)GetProcAddress(hDLL,"set_ellipse_ratio");
set_s_curve = (LPFNDLL2810_set_s_curve)GetProcAddress(hDLL,"set_s_curve");
set_s_section = (LPFNDLL2810_set_s_section)GetProcAddress(hDLL,"set_s_section");
set_abs_pos = (LPFNDLL2810_set_abs_pos)GetProcAddress(hDLL,"set_abs_pos");
reset_pos = (LPFNDLL2810_reset_pos)GetProcAddress(hDLL,"reset_pos");
set_unit = (LPFNDLL2810_set_unit)GetProcAddress(hDLL,"set_unit");
set_steps_pr = (LPFNDLL2810_set_steps_pr)GetProcAddress(hDLL,"set_steps_pr");
set_enc_thread = (LPFNDLL2810_set_enc_thread)GetProcAddress(hDLL,"set_enc_thread");
//运动函数
con_pmove = (LPFNDLL2810_con_pmove)GetProcAddress(hDLL,"con_pmove");
con_pmove2 = (LPFNDLL2810_con_pmove2)GetProcAddress(hDLL,"con_pmove2");
con_pmove3 = (LPFNDLL2810_con_pmove3)GetProcAddress(hDLL,"con_pmove3");
con_pmove4 = (LPFNDLL2810_con_pmove4)GetProcAddress(hDLL,"con_pmove4");
con_pmove_to = (LPFNDLL2810_con_pmove_to)GetProcAddress(hDLL,"con_pmove_to");
fast_pmove = (LPFNDLL2810_fast_pmove)GetProcAddress(hDLL,"fast_pmove");
fast_pmove2 = (LPFNDLL2810_fast_pmove2)GetProcAddress(hDLL,"fast_pmove2");
fast_pmove3 = (LPFNDLL2810_fast_pmove3)GetProcAddress(hDLL,"fast_pmove3");
fast_pmove4 = (LPFNDLL2810_fast_pmove4)GetProcAddress(hDLL,"fast_pmove4");
fast_pmove_to = (LPFNDLL2810_fast_pmove_to)GetProcAddress(hDLL,"fast_pmove_to");
con_vmove = (LPFNDLL2810_con_vmove)GetProcAddress(hDLL,"con_vmove");
con_vmove2 = (LPFNDLL2810_con_vmove2)GetProcAddress(hDLL,"con_vmove2");
con_vmove3 = (LPFNDLL2810_con_vmove3)GetProcAddress(hDLL,"con_vmove3");
con_vmove4 = (LPFNDLL2810_con_vmove4)GetProcAddress(hDLL,"con_vmove4");
fast_vmove = (LPFNDLL2810_fast_vmove)GetProcAddress(hDLL,"fast_vmove");
fast_vmove2 = (LPFNDLL2810_fast_vmove2)GetProcAddress(hDLL,"fast_vmove2");
fast_vmove3 = (LPFNDLL2810_fast_vmove3)GetProcAddress(hDLL,"fast_vmove3");
fast_vmove4 = (LPFNDLL2810_fast_vmove4)GetProcAddress(hDLL,"fast_vmove4");
con_hmove = (LPFNDLL2810_con_hmove)GetProcAddress(hDLL,"con_hmove");
con_hmove2 = (LPFNDLL2810_con_hmove2)GetProcAddress(hDLL,"con_hmove2");
con_hmove3 = (LPFNDLL2810_con_hmove3)GetProcAddress(hDLL,"con_hmove3");
con_hmove4 = (LPFNDLL2810_con_hmove4)GetProcAddress(hDLL,"con_hmove4");
fast_hmove = (LPFNDLL2810_fast_hmove)GetProcAddress(hDLL,"fast_hmove");
fast_hmove2 = (LPFNDLL2810_fast_hmove2)GetProcAddress(hDLL,"fast_hmove2");
fast_hmove3 = (LPFNDLL2810_fast_hmove3)GetProcAddress(hDLL,"fast_hmove3");
fast_hmove4 = (LPFNDLL2810_fast_hmove4)GetProcAddress(hDLL,"fast_hmove4");
con_line2 = (LPFNDLL2810_con_line2)GetProcAddress(hDLL,"con_line2");
con_line3 = (LPFNDLL2810_con_line3)GetProcAddress(hDLL,"con_line3");
con_line4 = (LPFNDLL2810_con_line4)GetProcAddress(hDLL,"con_line4");
con_linen_to = (LPFNDLL2810_con_linen_to)GetProcAddress(hDLL,"con_linen_to");
fast_line2 = (LPFNDLL2810_fast_line2)GetProcAddress(hDLL,"fast_line2");
fast_line3 = (LPFNDLL2810_fast_line3)GetProcAddress(hDLL,"fast_line3");
fast_line4 = (LPFNDLL2810_fast_line4)GetProcAddress(hDLL,"fast_line4");
fast_linen_to = (LPFNDLL2810_fast_linen_to)GetProcAddress(hDLL,"fast_linen_to");
arc_center = (LPFNDLL2810_arc_center)GetProcAddress(hDLL,"arc_center");
arc_final = (LPFNDLL2810_arc_final)GetProcAddress(hDLL,"arc_final");
fast_arc_center = (LPFNDLL2810_fast_arc_center)GetProcAddress(hDLL,"fast_arc_center");
helical_move = (LPFNDLL2810_helical_move)GetProcAddress(hDLL,"helical_move");
//制动函数
sudden_stop = (LPFNDLL2810_sudden_stop)GetProcAddress(hDLL,"sudden_stop");
sudden_stop2 = (LPFNDLL2810_sudden_stop2)GetProcAddress(hDLL,"sudden_stop2");
sudden_stop3 = (LPFNDLL2810_sudden_stop3)GetProcAddress(hDLL,"sudden_stop3");
sudden_stop4 = (LPFNDLL2810_sudden_stop4)GetProcAddress(hDLL,"sudden_stop4");
sudden_stop_list = (LPFNDLL2810_sudden_stop_list)GetProcAddress(hDLL,"sudden_stop_list");
decel_stop = (LPFNDLL2810_decel_stop)GetProcAddress(hDLL,"decel_stop");
decel_stop2 = (LPFNDLL2810_decel_stop2)GetProcAddress(hDLL,"decel_stop2");
decel_stop3 = (LPFNDLL2810_decel_stop3)GetProcAddress(hDLL,"decel_stop3");
decel_stop4 = (LPFNDLL2810_decel_stop4)GetProcAddress(hDLL,"decel_stop4");
decel_stop_list = (LPFNDLL2810_decel_stop_list)GetProcAddress(hDLL,"decel_stop_list");
move_pause = (LPFNDLL2810_move_pause)GetProcAddress(hDLL,"move_pause");
move_pause_list = (LPFNDLL2810_move_pause_list)GetProcAddress(hDLL,"move_pause_list");
move_resume = (LPFNDLL2810_move_resume)GetProcAddress(hDLL,"move_resume");
move_resume_list = (LPFNDLL2810_move_resume_list)GetProcAddress(hDLL,"move_resume_list");
delay_time = (LPFNDLL2810_delay_time)GetProcAddress(hDLL,"delay_time");
//I/O口操作函数
checkin_byte = (LPFNDLL2810_checkin_byte)GetProcAddress(hDLL,"checkin_byte");
checkin_bit = (LPFNDLL2810_checkin_bit)GetProcAddress(hDLL,"checkin_bit");
outport_bit = (LPFNDLL2810_outport_bit)GetProcAddress(hDLL,"outport_bit");
outport_byte = (LPFNDLL2810_outport_byte)GetProcAddress(hDLL,"outport_byte");
check_sfr = (LPFNDLL2810_check_sfr)GetProcAddress(hDLL,"check_sfr");
check_sfr_bit = (LPFNDLL2810_check_sfr_bit)GetProcAddress(hDLL,"check_sfr_bit");
Outport = (LPFNDLL2810_Outport)GetProcAddress(hDLL,"Outport");
Inport = (LPFNDLL2810_Inport)GetProcAddress(hDLL,"Inport");
//特殊功能
set_backlash = (LPFNDLL2810_set_backlash)GetProcAddress(hDLL,"set_backlash");
start_backlash = (LPFNDLL2810_start_backlash)GetProcAddress(hDLL,"start_backlash");
end_backlash = (LPFNDLL2810_end_backlash)GetProcAddress(hDLL,"end_backlash");
set_watchdog_time = (LPFNDLL2810_set_watchdog_time)GetProcAddress(hDLL,"set_watchdog_time");
reset_watchdog = (LPFNDLL2810_reset_watchdog)GetProcAddress(hDLL,"reset_watchdog");
start_watchdog = (LPFNDLL2810_start_watchdog)GetProcAddress(hDLL,"start_watchdog");
stop_watchdog = (LPFNDLL2810_stop_watchdog)GetProcAddress(hDLL,"stop_watchdog");
get_watchdog_status = (LPFNDLL2810_get_watchdog_status)GetProcAddress(hDLL,"get_watchdog_status");
enable_io_pos = (LPFNDLL2810_enable_io_pos)GetProcAddress(hDLL,"enable_io_pos");
set_poscmp_source = (LPFNDLL2810_set_poscmp_source)GetProcAddress(hDLL,"set_poscmp_source");
set_io_pos = (LPFNDLL2810_set_io_pos)GetProcAddress(hDLL,"set_io_pos");
enable_lock_enc = (LPFNDLL2810_enable_lock_enc)GetProcAddress(hDLL,"enable_lock_enc");
reset_locked_flag = (LPFNDLL2810_reset_locked_flag)GetProcAddress(hDLL,"reset_locked_flag");
get_locked_flag = (LPFNDLL2810_get_locked_flag)GetProcAddress(hDLL,"get_locked_flag");
get_locked_encoder = (LPFNDLL2810_get_locked_encoder)GetProcAddress(hDLL,"get_locked_encoder");
enable_gear = (LPFNDLL2810_enable_gear)GetProcAddress(hDLL,"enable_gear");
enable_handwheel = (LPFNDLL2810_enable_handwheel)GetProcAddress(hDLL,"enable_handwheel");
enable_softlimit = (LPFNDLL2810_enable_softlimit)GetProcAddress(hDLL,"enable_softlimit");
set_softlimit = (LPFNDLL2810_set_softlimit)GetProcAddress(hDLL,"set_softlimit");
set_softlimit_data = (LPFNDLL2810_set_softlimit_data)GetProcAddress(hDLL,"set_softlimit_data");
check_softlimit = (LPFNDLL2810_check_softlimit)GetProcAddress(hDLL,"check_softlimit");
enable_poserr_limit = (LPFNDLL2810_enable_poserr_limit)GetProcAddress(hDLL,"enable_poserr_limit");
set_poserr_limit = (LPFNDLL2810_set_poserr_limit)GetProcAddress(hDLL,"set_poserr_limit");
get_poserr_limit = (LPFNDLL2810_get_poserr_limit)GetProcAddress(hDLL,"get_poserr_limit");
enable_input_mode = (LPFNDLL2810_enable_input_mode)GetProcAddress(hDLL,"enable_input_mode");
set_im_deadband = (LPFNDLL2810_set_im_deadband)GetProcAddress(hDLL,"set_im_deadband");
enable_isr = (LPFNDLL2810_enable_isr)GetProcAddress(hDLL,"enable_isr");
set_isr_routine = (LPFNDLL2810_set_isr_routine)GetProcAddress(hDLL,"set_isr_routine");
set_isr_factor = (LPFNDLL2810_set_isr_factor)GetProcAddress(hDLL,"set_isr_factor");
get_isr_event = (LPFNDLL2810_get_isr_event)GetProcAddress(hDLL,"get_isr_event");
set_ramp = (LPFNDLL2810_set_ramp)GetProcAddress(hDLL,"set_ramp");
change_speed = (LPFNDLL2810_change_speed)GetProcAddress(hDLL,"change_speed");
change_pos = (LPFNDLL2810_change_pos)GetProcAddress(hDLL,"change_pos");
set_tan_flag = (LPFNDLL2810_set_tan_flag)GetProcAddress(hDLL,"set_tan_flag");
set_tan_initpos = (LPFNDLL2810_set_tan_initpos)GetProcAddress(hDLL,"set_tan_initpos");
set_tan_map = (LPFNDLL2810_set_tan_map)GetProcAddress(hDLL,"set_tan_map");
set_tan_axis = (LPFNDLL2810_set_tan_axis)GetProcAddress(hDLL,"set_tan_axis");
//位置和状态查询函数
get_max_axe = (LPFNDLL2810_get_max_axe)GetProcAddress(hDLL,"get_max_axe");
get_board_num = (LPFNDLL2810_get_board_num)GetProcAddress(hDLL,"get_board_num");
get_axe = (LPFNDLL2810_get_axe)GetProcAddress(hDLL,"get_axe");
get_unit = (LPFNDLL2810_get_unit)GetProcAddress(hDLL,"get_unit");
check_IC = (LPFNDLL2810_check_IC)GetProcAddress(hDLL,"check_IC");
get_abs_pos = (LPFNDLL2810_get_abs_pos)GetProcAddress(hDLL,"get_abs_pos");
get_rel_pos = (LPFNDLL2810_get_rel_pos)GetProcAddress(hDLL,"get_rel_pos");
get_encoder = (LPFNDLL2810_get_encoder)GetProcAddress(hDLL,"get_encoder");
get_done_source = (LPFNDLL2810_get_done_source)GetProcAddress(hDLL,"get_done_source");
get_cur_dir = (LPFNDLL2810_get_cur_dir)GetProcAddress(hDLL,"get_cur_dir");
get_conspeed = (LPFNDLL2810_get_conspeed)GetProcAddress(hDLL,"get_conspeed");
get_profile = (LPFNDLL2810_get_profile)GetProcAddress(hDLL,"get_profile");
get_vector_conspeed = (LPFNDLL2810_get_vector_conspeed)GetProcAddress(hDLL,"get_vector_conspeed");
get_vector_profile = (LPFNDLL2810_get_vector_profile)GetProcAddress(hDLL,"get_vector_profile");
get_rate = (LPFNDLL2810_get_rate)GetProcAddress(hDLL,"get_rate");
check_status = (LPFNDLL2810_check_status)GetProcAddress(hDLL,"check_status");
check_done = (LPFNDLL2810_check_done)GetProcAddress(hDLL,"check_done");
check_limit = (LPFNDLL2810_check_limit)GetProcAddress(hDLL,"check_limit");
check_home = (LPFNDLL2810_check_home)GetProcAddress(hDLL,"check_home");
check_SD = (LPFNDLL2810_check_SD)GetProcAddress(hDLL,"check_SD");
check_alarm = (LPFNDLL2810_check_alarm)GetProcAddress(hDLL,"check_alarm");
//V0.2.2增加
check_delay_status = (LPFNDLL2810_check_delay_status)GetProcAddress(hDLL,"check_delay_status");
get_cmd_counter = (LPFNDLL2810_get_cmd_counter)GetProcAddress(hDLL,"get_cmd_counter");
reset_cmd_counter = (LPFNDLL2810_reset_cmd_counter)GetProcAddress(hDLL,"reset_cmd_counter");
get_lib_ver = (LPFNDLL2810_get_lib_ver)GetProcAddress(hDLL,"get_lib_ver");
get_sys_ver = (LPFNDLL2810_get_sys_ver)GetProcAddress(hDLL,"get_sys_ver");
get_card_ver = (LPFNDLL2810_get_card_ver)GetProcAddress(hDLL,"get_card_ver");
//错误代码处理
get_err = (LPFNDLL2810_get_err)GetProcAddress(hDLL,"get_err");
get_last_err = (LPFNDLL2810_get_last_err)GetProcAddress(hDLL,"get_last_err");
reset_err = (LPFNDLL2810_reset_err)GetProcAddress(hDLL,"reset_err");
////////////////////////////////////////////////////////////////////
//若无法取得函数指针
if (!auto_set||!init_board)
{
// handle the error
FreeLibrary(hDLL);
return -1;
}
else
{
return 0;
}
}
else
{
return -1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -