实例介绍
【实例简介】
【实例截图】
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace 练习2
{
public class Dmc2410
{
//---------------------板卡初始和配置函数DMC2480 ----------------------
/********************************************************************************
** 函数名称: d2410_board_init
** 功能描述: 控制板初始化,设置初始化和速度等设置
** 输 入: 无
** 返 回 值: 0:无卡; 1-8:成功(实际卡数)
** 1001 j: j号卡初始化出错 从1001开始。
** 修 改:
** 修改日期:
*********************************************************************************/
[DllImport("Dmc2410.dll", EntryPoint = "d2410_board_init", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt16 d2410_board_init();
/********************************************************************************
** 函数名称: d2410_board_close
** 功能描述: 关闭所有卡
** 输 入: 无
** 返 回 值: 无
** 日 期:
*********************************************************************************/
[DllImport("Dmc2410.dll", EntryPoint = "d2410_board_close", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_board_close();
/********************************************************************************
** 函数名称: 控制卡复位
** 功能描述: 复位所有卡,只能在初始化完成之后调用.
** 输 入: 无
** 返 回 值: 无
** 日 期:
*********************************************************************************/
[DllImport("Dmc2410.dll", EntryPoint = "d2410_board_rest", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_board_rest();
//脉冲输入输出配置
[DllImport("Dmc2410.dll", EntryPoint = "d2410_set_pulse_outmode", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_set_pulse_outmode(UInt16 axis, UInt16 outmode);
//专用信号设置函数
[DllImport("Dmc2410.dll", EntryPoint = "d2410_config_ALM_PIN", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_config_ALM_PIN(UInt16 axis, UInt16 alm_logic, UInt16 alm_action);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_config_ALM_PIN_Extern", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_config_ALM_PIN_Extern(UInt16 axis, UInt16 alm_enbale, UInt16 alm_logic, UInt16 alm_all, UInt16 alm_action);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_config_EL_MODE", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_config_EL_MODE(UInt16 axis, UInt16 el_mode);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_set_HOME_pin_logic", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_set_HOME_pin_logic(UInt16 axis, UInt16 org_logic, UInt16 filter);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_write_SEVON_PIN", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_write_SEVON_PIN(UInt16 axis, UInt16 on_off);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_read_SEVON_PIN", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 d2410_read_SEVON_PIN(UInt16 axis);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_read_RDY_PIN", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 d2410_read_RDY_PIN(UInt16 axis);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_Enable_EL_PIN", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_Enable_EL_PIN(UInt16 axis, UInt16 enable);
//通用输入/输出控制函数
[DllImport("Dmc2410.dll", EntryPoint = "d2410_read_inbit", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 d2410_read_inbit(UInt16 cardno, UInt16 bitno);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_write_outbit", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_write_outbit(UInt16 cardno, UInt16 bitno, UInt16 on_off);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_read_outbit", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 d2410_read_outbit(UInt16 cardno, UInt16 bitno);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_read_inport", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 d2410_read_inport(UInt16 cardno);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_read_outport", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 d2410_read_outport(UInt16 cardno);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_write_outport", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_write_outport(UInt16 cardno, UInt32 port_value);
//制动函数
[DllImport("Dmc2410.dll", EntryPoint = "d2410_decel_stop", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_decel_stop(UInt16 axis, double Tdec);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_imd_stop", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_imd_stop(UInt16 axis);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_emg_stop", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_emg_stop();
//位置设置和读取函数
[DllImport("Dmc2410.dll", EntryPoint = "d2410_get_position", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 d2410_get_position(UInt16 axis);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_set_position", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_set_position(UInt16 axis, Int32 current_position);
//状态检测函数
[DllImport("Dmc2410.dll", EntryPoint = "d2410_check_done", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt16 d2410_check_done(UInt16 axis);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_axis_io_status", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt16 d2410_axis_io_status(UInt16 axis);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_get_rsts", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_get_rsts(UInt16 axis);
//速度设置和读取函数
[DllImport("Dmc2410.dll", EntryPoint = "d2410_set_vector_profile", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_set_vector_profile(double Min_Vel, double Max_Vel, double Tacc, double Tdec);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_set_profile", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_set_profile(UInt16 axis, double Min_Vel, double Max_Vel, double Tacc, double Tdec);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_set_profile_Extern", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_set_profile_Extern(UInt16 axis, double Min_Vel, double Max_Vel, double Tacc, double Tdec,double Stop_Vel);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_set_s_profile", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_set_s_profile(UInt16 axis, double Min_Vel, double Max_Vel, double Tacc, double Tdec, Int32 Sacc, Int32 Sdec);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_set_st_profile", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_set_st_profile(UInt16 axis, double Min_Vel, double Max_Vel, double Tacc, double Tdec, double Tsacc, double Tsdec);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_read_current_speed", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern double d2410_read_current_speed(UInt16 axis);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_read_vector_speed", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern double d2410_read_vector_speed(UInt16 card);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_set_st_profile_Extern", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_set_st_profile_Extern(UInt16 axis, double Min_Vel, double Max_Vel, double Tacc, double Tdec, double Tsacc, double Tsdec, double Stop_Vel);
//在线变速/变位
[DllImport("Dmc2410.dll", EntryPoint = "d2410_change_speed", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_change_speed(UInt16 axis, double Curr_Vel);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_reset_target_position", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_reset_target_position(UInt16 axis, Int32 dist);
//单轴定长运动
[DllImport("Dmc2410.dll", EntryPoint = "d2410_t_pmove", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_t_pmove(UInt16 axis, Int32 Dist, UInt16 posi_mode);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_ex_t_pmove", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_ex_t_pmove(UInt16 axis, Int32 Dist, UInt16 posi_mode);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_s_pmove", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_s_pmove(UInt16 axis, Int32 Dist, UInt16 posi_mode);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_ex_s_pmove", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_ex_s_pmove(UInt16 axis, Int32 Dist, UInt16 posi_mode);
//单轴连续运动
[DllImport("Dmc2410.dll", EntryPoint = "d2410_s_vmove", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_s_vmove(UInt16 axis, UInt16 dir);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_t_vmove", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_t_vmove(UInt16 axis, UInt16 dir);
//直线插补
[DllImport("Dmc2410.dll", EntryPoint = "d2410_t_line2", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_t_line2(UInt16 axis1, Int32 Dist1, UInt16 axis2, Int32 Dist2, UInt16 posi_mode);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_t_line3", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_t_line3(UInt16[] axis, Int32 Dist1, Int32 Dist2, Int32 Dist3, UInt16 posi_mode);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_t_line4", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_t_line4(UInt16 cardno, Int32 Dist1, Int32 Dist2, Int32 Dist3, Int32 Dist4, UInt16 posi_mode);
//圆弧插补
[DllImport("Dmc2410.dll", EntryPoint = "d2410_arc_move", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_arc_move(UInt16[] axis, Int32[] target_pos, Int32[] cen_pos, UInt16 arc_dir);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_rel_arc_move", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_rel_arc_move(UInt16[] axis, Int32[] rel_pos, Int32[] rel_cen, UInt16 arc_dir);
//手轮运动
[DllImport("Dmc2410.dll", EntryPoint = "d2410_set_handwheel_inmode", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_set_handwheel_inmode(UInt16 axis, UInt16 inmode, double multi);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_handwheel_move", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_handwheel_move(UInt16 axis);
//找原点
[DllImport("Dmc2410.dll", EntryPoint = "d2410_config_home_mode", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_config_home_mode(UInt16 axis, UInt16 mode, UInt16 EZ_count);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_home_move", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_home_move(UInt16 axis, UInt16 home_mode, UInt16 vel_mode);
//原点锁存
[DllImport("Dmc2410.dll", EntryPoint = "d2410_set_homelatch_mode", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_set_homelatch_mode(UInt16 axis,UInt16 enable,UInt16 logic);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_get_homelatch_mode", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_get_homelatch_mode(UInt16 axis,ref UInt16 enable,ref UInt16 logic);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_get_homelatch_flag", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 d2410_get_homelatch_flag(UInt16 axis);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_reset_homelatch_flag", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_reset_homelatch_flag(UInt16 axis);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_get_homelatch_value", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 d2410_get_homelatch_value(UInt16 axis);
//多组位置比较函数
[DllImport("Dmc2410.dll", EntryPoint = "d2410_compare_config_Extern", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_compare_config_Extern(UInt16 card,UInt16 queue, UInt16 enable, UInt16 axis, UInt16 cmp_source);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_compare_get_config_Extern", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_compare_get_config_Extern(UInt16 card,UInt16 queue, ref UInt16 enable, ref UInt16 axis, ref UInt16 cmp_source);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_compare_clear_points_Extern", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_compare_clear_points_Extern(UInt16 card,UInt16 queue);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_compare_add_point_Extern", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_compare_add_point_Extern(UInt16 card,UInt16 queue, UInt32 pos, UInt16 dir, UInt16 action, UInt32 actpara);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_compare_get_current_point_Extern", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 d2410_compare_get_current_point_Extern(UInt16 card,UInt16 queue);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_compare_get_points_runned_Extern", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 d2410_compare_get_points_runned_Extern(UInt16 card,UInt16 queue);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_compare_get_points_remained_Extern", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 d2410_compare_get_points_remained_Extern(UInt16 card,UInt16 queue);
//高速位置比较
[DllImport("Dmc2410.dll", EntryPoint = "d2410_config_CMP_PIN", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_config_CMP_PIN(UInt16 axis, UInt16 cmp_enable,Int32 cmp_pos, UInt16 CMP_logic);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_get_config_CMP_PIN", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_get_config_CMP_PIN(UInt16 axis, ref UInt16 cmp_enable,ref Int32 cmp_pos, ref UInt16 CMP_logic);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_read_CMP_PIN", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 d2410_read_CMP_PIN(UInt16 axis);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_write_CMP_PIN", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_write_CMP_PIN(UInt16 axis,UInt16 on_off);
//编码器计数功能
[DllImport("Dmc2410.dll", EntryPoint = "d2410_get_encoder", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 d2410_get_encoder(UInt16 axis);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_set_encoder", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_set_encoder(UInt16 axis, UInt32 encoder_value);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_config_EZ_PIN", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_config_EZ_PIN(UInt16 axis, UInt16 ez_logic, UInt16 ez_mode);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_get_counter_flag", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_get_counter_flag(UInt16 cardno);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_reset_counter_flag", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_reset_counter_flag(UInt16 cardno);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_reset_clear_flag", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_reset_clear_flag(UInt16 cardno);
//高速锁存
[DllImport("Dmc2410.dll", EntryPoint = "d2410_config_LTC_PIN", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_config_LTC_PIN(UInt16 axis, UInt16 ltc_logic, UInt16 ltc_mode);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_config_LTC_PIN_Extern", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_config_LTC_PIN_Extern(UInt16 axis, UInt16 ltc_logic, UInt16 ltc_mode,double ltc_filter);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_config_latch_mode", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_config_latch_mode(UInt16 cardno, UInt16 all_enable);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_counter_config", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_counter_config(UInt16 axis, UInt16 mode);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_get_latch_value", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_get_latch_value(UInt16 axis);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_get_latch_flag", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_get_latch_flag(UInt16 cardno);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_reset_latch_flag", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_reset_latch_flag(UInt16 cardno);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_triger_chunnel", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_triger_chunnel(UInt16 cardno, UInt16 num);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_set_speaker_logic", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_set_speaker_logic(UInt16 cardno, UInt16 logic);
//EMG设置
[DllImport("Dmc2410.dll", EntryPoint = "d2410_config_EMG_PIN", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_config_EMG_PIN(UInt16 cardno, UInt16 enable, UInt16 emg_logic);
//软件限位功能
[DllImport("Dmc2410.dll", EntryPoint = "d2410_config_softlimit", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_config_softlimit(UInt16 axis,UInt16 ON_OFF, UInt16 source_sel,UInt16 SL_action, Int32 N_limit,Int32 P_limit);
[DllImport("Dmc2410.dll", EntryPoint = "d2410_get_config_softlimit", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern UInt32 d2410_get_config_softlimit(UInt16 axis,ref UInt16 ON_OFF, ref UInt16 source_sel,ref UInt16 SL_action, ref Int32 N_limit,ref Int32 P_limit);
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 练习2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
int n;
n = Dmc2410.d2410_board_init();//初始化
if(n<1||n>8)
{
MessageBox.Show("未找到控制卡");
}
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
Dmc2410.d2410_board_close();//关闭
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if(checkBox1.Checked==true)
{
Dmc2410.d2410_write_outbit(0, 1, 0);//0为高1为低
checkBox1.Text = "输出口1:高电平";
}
else
{
Dmc2410.d2410_write_outbit(0, 1, 1);
checkBox1.Text = "输出口1:低电平";
}
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
if (checkBox2.Checked == true)
{
Dmc2410.d2410_write_outbit(0, 2, 0);
checkBox2.Text = "输出口2:高电平";
}
else
{
Dmc2410.d2410_write_outbit(0, 2, 1);
checkBox2.Text = "输出口2:低电平";
}
}
private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
if(checkBox3.Checked==true)
{
Dmc2410.d2410_write_outbit(0, 3, 0);
checkBox3.Text = "输出口3:高电平";
}
else
{
Dmc2410.d2410_write_outbit(0, 3, 1);
checkBox3.Text = "输出口3:低电平";
}
}
private void checkBox4_CheckedChanged(object sender, EventArgs e)
{
if(checkBox4.Checked==true)
{
Dmc2410.d2410_write_outbit(0, 4, 0);
checkBox4.Text = "输出口4:高电平";
}
else
{
Dmc2410.d2410_write_outbit(0, 4, 1);
checkBox4.Text = "输出口4:低电平";
}
}
private void checkBox5_CheckedChanged(object sender, EventArgs e)
{
if(checkBox5.Checked==true)
{
Dmc2410.d2410_write_SEVON_PIN(0, 0);
checkBox5.Text="伺服使能:ON";
}
else
{
Dmc2410.d2410_write_SEVON_PIN(0, 1);
checkBox5.Text = "伺服使能:OFF";
}
}
private void timer1_Tick(object sender, EventArgs e)
{
label2.Text = "输入口1:" Convert.ToString(Dmc2410.d2410_read_inbit(0, 1)) "输入口2:"
Convert.ToString(Dmc2410.d2410_read_inbit(0, 2)) "输入口3:" Convert.ToString(Dmc2410.d2410_read_inbit(0, 3))
"输入口4:" Convert.ToString(Dmc2410.d2410_read_inbit(0, 4));
label1.Text = "X轴原点" Convert.ToString(Dmc2410.d2410_axis_io_status(0) & (2 ^ 14));
}
}
}
好例子网口号:伸出你的我的手 — 分享!
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明


网友评论
我要评论