Exemple #1
0
        public bool   resetCar()     // 重启运动控制卡      报警
        {
            LTDMC.dmc_soft_reset(CarNum);
            LTDMC.dmc_board_reset();
            LTDMC.dmc_board_close();

            for (int i = 0; i < 15; i++)//总线卡软件复位耗时15s左右
            {
                Thread.Sleep(1000);
                Global.frmMain.PushMess(i + "/15....");
            }
            var a = LTDMC.dmc_board_init();

            Global.frmMain.PushMess("Card Number: " + a + "");
            if (a > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
            // Axis.nmc_get_errcode(MyGlobal._CarId, 2, ref errcode);
            //  mess_textBox.AppendText("总线卡软件复位完成,请确认总线状态" + errcode.ToString());
        }
        private void FrMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            LTDMC.dmc_emg_stop(0);  //停轴


            LTDMC.nmc_set_axis_disable(0, 0);
            LTDMC.nmc_set_axis_disable(0, 1);
            LTDMC.nmc_set_axis_disable(0, 2);
            LTDMC.nmc_set_axis_disable(0, 3);
            LTDMC.nmc_set_axis_disable(0, 4);
            LTDMC.dmc_board_close();
            if (VarClass.Homeing)   //归零中
            {
                myPublicClass.myHomeThread.Abort();
            }
            if (VarClass.Autoing)   //自动中
            {
                myPublicClass.myAutoThread.Abort();
            }
            myCycleThread.Abort();
            try
            {
                Environment.Exit(0);
            }
            catch (Exception ex)
            { }
        }
Exemple #3
0
 /// <summary>
 /// 关闭所有控制卡
 /// </summary>
 public static void CloseCard()
 {
     try
     {
         LTDMC.dmc_board_close();
     }
     catch (Exception ex)
     {
         m_logFile.AppendText(ex.Message);
     }
 }
 /// <summary>
 /// 窗口关闭事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void 机械臂控制软件界面_FormClosed(object sender, FormClosedEventArgs e)
 {
     m_thread.Abort();
     try
     {
         //关闭串口
         robot1.CloseCom();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "串口关闭错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     CloseMatlab();
     LTDMC.dmc_board_close();
 }
 private void AppClosedEventCommandExecute()
 {
     try
     {
         for (int i = 0; i < 4; i++)
         {
             Res = LTDMC.dmc_write_sevrst_pin(_CardID, (ushort)i, 1);
             Res = LTDMC.dmc_write_sevon_pin(_CardID, (ushort)i, 1);
         }
         for (int i = 0; i < 16; i++)
         {
             Res = LTDMC.dmc_write_outbit(_CardID, (ushort)i, 1);
         }
         LTDMC.dmc_board_close();
     }
     catch { }
 }
Exemple #6
0
 public bool Terminate()
 {
     LTDMC.dmc_board_close();
     return(true);
 }
Exemple #7
0
        /// <summary>
        /// 关闭板卡。先关从卡再关主卡。
        /// </summary>
        /// <returns></returns>
        public EM_RES Close()
        {
            if (!isInit)
            {
                return(EM_RES.OK);
            }

            int ret;

#if LEADSHINE
            if (brand == BRAND.LEADSHINE)
            {
                if (type == TYPE.MOTION)
                {
                    //axis dec stop
                    for (int n = 0; n < ax_num; n++)
                    {
                        LTDMC.dmc_stop((ushort)card_id, (ushort)n, 0);
                        Thread.Sleep(10);
                    }

                    ret = LTDMC.dmc_board_close();
                    if (ret != 0)
                    {
                        VAR.msg.AddMsg(Msg.EM_MSGTYPE.SYS, string.Format("{0}关闭失败,Err:0x{1:X8}", disc, ret));
                        return(EM_RES.ERR);
                    }
                    VAR.msg.AddMsg(Msg.EM_MSGTYPE.SYS, string.Format("{0}关闭成功", disc));
                    isInit = false;
                    return(EM_RES.OK);
                }
                else if (type == TYPE.CAN_IO)
                {
                    //连接IO卡
                    ret = LTDMC.dmc_set_can_state((ushort)maincard_id, (ushort)card_id, 0, 0);
                    if (ret != 0)
                    {
                        VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, string.Format("{0}断开失败,Err:0x{1:X8}", disc, ret));
                        return(EM_RES.ERR);
                    }
                    VAR.msg.AddMsg(Msg.EM_MSGTYPE.SYS, string.Format("{0}断开成功", disc));
                    isInit = false;
                    return(EM_RES.OK);
                }
#if LEADSHINE_IO
                else if (type == TYPE.IO)
                {
                    IOC0640.ioc_board_close();
                    isInit = false;
                    VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, string.Format("{0}关闭成功", disc));
                    return(EM_RES.OK);
                }
#endif
            }
#endif
#if ZMOTION
            if (brand == BRAND.ZMOTION)
            {
                if (handle != (IntPtr)0)
                {
                    ret = zmcaux.ZAux_Close(handle);
                    if (ret != 0)
                    {
                        VAR.msg.AddMsg(Msg.EM_MSGTYPE.SYS, string.Format("{0}关闭失败,Err:0x{1:X8}", disc, ret));
                        return(EM_RES.ERR);
                    }
                    handle = (IntPtr)0;
                    isInit = false;
                    VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, string.Format("{0}关闭成功", disc));
                    return(EM_RES.OK);
                }
                return(EM_RES.OK);
            }
#endif
#if ADVANTTECK
            if (brand == BRAND.ADVANTTECH)
            {
                isInit = false;
                VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, "研华库未添加!");
                return(EM_RES.ERR);
            }
#endif
#if ORIENTALMOTOR
            if (brand == BRAND.ORIENTALMOTOR)
            {
                if (AZD.Motor.Close())
                {
                    isInit = false;
                    return(EM_RES.OK);
                }
                else
                {
                    return(EM_RES.ERR);
                }
            }
#endif
            VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, string.Format("未定义异常,BRAND={0},TYPE={1}", brand, type));
            return(EM_RES.ERR);
        }
Exemple #8
0
        public EM_RES DownLoadFile(string filename = "")
        {
            int ret = 0;

            //if (!isReady) return EM_RES.ERR;
#if LEADSHINE
            if (brand == BRAND.LEADSHINE)
            {
                //download config
                if (filename == "")
                {
                    filename = string.Format("{0}DMC3800_{1}.ini", Path.GetFullPath("..") + "\\syscfg\\", card_id);
                }
                VAR.msg.AddMsg(Msg.EM_MSGTYPE.SYS, String.Format("{0}下载配置,{1}", str_disc, filename));
                ret = LTDMC.dmc_download_configfile((ushort)card_id, filename);
                if (ret != 0)
                {
                    LTDMC.dmc_board_close();
                    isInit = false;
                    VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, String.Format("{0}/id{1},配置失败!Err:0x{2:X8}", disc, card_id, ret));
                    return(EM_RES.ERR);
                }
                else
                {
                    VAR.msg.AddMsg(Msg.EM_MSGTYPE.SYS, String.Format("{0}/id{1},更新配置成功!", disc, card_id));
                }
            }
#endif
#if ZMOTION
            if (brand == BRAND.ZMOTION)
            {
                //下载时,容易引起程序丢失
                //if (filename == "") filename = string.Format("{0}{1}_{2}.bas", Path.GetFullPath("..") + "\\syscfg\\", str_disc, id);
                //VAR.msg.AddMsg(Msg.EM_MSGTYPE.SYS, String.Format("{0}下载配置,{1}", str_disc, filename));
                //ret = zmcaux.ZAux_BasDown(handle, filename);
                //if (ret != 0)
                //{
                //    isInit = false;
                //    zmcaux.ZAux_Close(handle);
                //    handle = (IntPtr)0;
                //    VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, string.Format("{0} 下载配置失败,Err:{1},{2}", disc, ret, filename));
                //    return EM_RES.ERR;
                //}
                //else
                //{
                //    //set max_spd
                //    foreach (AXIS ax in AxList)
                //    {
                //        zmcaux.ZAux_Direct_SetMaxSpeed(handle, ax.num, (int)(ax.max_spd * ax.pul_per_mm));
                //        if (ret != 0)
                //        {
                //            VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, string.Format("{0} 配置MAX_SPD失败,Err:{1}", disc, ret));
                //        }
                //    }
                //    VAR.msg.AddMsg(Msg.EM_MSGTYPE.SYS, String.Format("{0}/id{1},更新配置成功!", disc, id));
                //}
            }
#endif
#if ORIENTALMOTOR
            if (brand == BRAND.ORIENTALMOTOR)
            {
                if (!Motor.isRs485Ready)
                {
                    EM_RES res = Init();
                    if (res != EM_RES.OK)
                    {
                        return(res);
                    }
                }
                VAR.msg.AddMsg(Msg.EM_MSGTYPE.SYS, String.Format("{0}下载配置", str_disc));
                foreach (AXIS ax in AxList)
                {
                    UInt32   temp  = 0;
                    UInt32   temp2 = 0;
                    ushort[] dat;
                    bool     bres = true;

                    ////(ZHOME)•运行速度 688/689
                    ////(ZHOME)•加减速 690/691
                    //temp = (ushort)(ax.home_spd * ax.pul_per_mm);
                    //temp2 = (ushort)(ax.tacc / 0.001);
                    //dat = new ushort[4] { (ushort)(temp >> 16), (ushort)(temp & 0XFFFF), (ushort)(temp2 >> 16), (ushort)(temp2 & 0XFFFF) };
                    //bres = ax.AzdMotor.WriteReg(688, dat);
                    //if(!bres)
                    //{
                    //    VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, string.Format("{0}设置运行速度/加速出错!",ax.disc));
                    //    return EM_RES.ERR;
                    //}
                    ////SLN作为 原点/预置位置 908/909
                    //temp = (ushort)(ax.sln * ax.pul_per_mm);
                    //dat = new ushort[2] { (ushort)(temp >> 16), (ushort)(temp & 0XFFFF) };
                    //bres = ax.AzdMotor.WriteReg(908, dat);
                    //if (!bres)
                    //{
                    //    VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, string.Format("{0}设置原点出错!", ax.disc));
                    //    return EM_RES.ERR;
                    //}

                    //POS0点数据 1024/1025
                    //POS1点数据 1026/1027
                    temp  = (ushort)(ax.pos0 * ax.pul_per_mm);
                    temp2 = (ushort)(ax.pos1 * ax.pul_per_mm);
                    dat   = new ushort[4] {
                        (ushort)(temp >> 16), (ushort)(temp & 0XFFFF), (ushort)(temp2 >> 16), (ushort)(temp2 & 0XFFFF)
                    };
                    bres = ax.AzdMotor.WriteReg(1024, dat);
                    if (!bres)
                    {
                        VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, string.Format("{0}设置POS0/POS1出错!", ax.disc));
                        return(EM_RES.ERR);
                    }

                    ////速度No.0 1152/1153
                    ////速度No.1 1154/1155
                    //temp = (ushort)(ax.spd_work * ax.pul_per_mm);
                    //dat = new ushort[4] { (ushort)(temp >> 16), (ushort)(temp & 0XFFFF), (ushort)(temp >> 16), (ushort)(temp & 0XFFFF) };
                    //bres = ax.AzdMotor.WriteReg(1152,dat);
                    //if (!bres)
                    //{
                    //    VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, string.Format("{0}设置速度0/速度1出错!", ax.disc));
                    //    return EM_RES.ERR;
                    //}

                    ////方式No.0 1280/1281 1-绝对定位
                    ////方式No.1 1282/1283 1-绝对定位
                    //dat = new ushort[4] { 0, 1, 0, 1 };
                    //bres = ax.AzdMotor.WriteReg(1280, dat);
                    //if (!bres)
                    //{
                    //    VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, string.Format("{0}设置定位方式0/1出错!", ax.disc));
                    //    return EM_RES.ERR;
                    //}

                    ////加减速单位 654/655 0:•kHz/s• 1:•s• 2:•ms / kHz
                    //dat = new ushort[2] { 0,1 };
                    //bres = ax.AzdMotor.WriteReg(654, dat);
                    //if (!bres)
                    //{
                    //    VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, string.Format("{0}设置加减速单位出错!", ax.disc));
                    //    return EM_RES.ERR;
                    //}

                    ////起动/变速No.0 1536/1537
                    ////起动/变速No.1 1538/1539
                    //temp = (ushort)(ax.tacc/0.001);
                    //dat = new ushort[4] { (ushort)(temp >> 16), (ushort)(temp & 0XFFFF), (ushort)(temp >> 16), (ushort)(temp & 0XFFFF) };
                    //bres = ax.AzdMotor.WriteReg(1536, dat);
                    //if (!bres)
                    //{
                    //    VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, string.Format("{0}设置加速度出错!", ax.disc));
                    //    return EM_RES.ERR;
                    //}

                    ////停止No.0 1664/1665
                    ////停止No.1 1666/1667
                    //temp = (ushort)(ax.tdec / 0.001);
                    //dat = new ushort[4] { (ushort)(temp >> 16), (ushort)(temp & 0XFFFF), (ushort)(temp >> 16), (ushort)(temp & 0XFFFF) };
                    //bres = ax.AzdMotor.WriteReg(1664, dat);
                    //if (!bres)
                    //{
                    //    VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, string.Format("{0}设置减速度出错!", ax.disc));
                    //    return EM_RES.ERR;
                    //}
                    return(EM_RES.OK);
                }
            }
#endif
            return(EM_RES.OK);
        }
Exemple #9
0
 private void Form1_FormClosed(object sender, FormClosedEventArgs e)
 {
     LTDMC.dmc_board_close();
 }
Exemple #10
0
        /// <summary>
        /// 关闭控制卡
        /// </summary>
        /// <returns></returns>
        public int CloseMotionCard()
        {
            int Flag = LTDMC.dmc_board_close();

            return(Flag);
        }
Exemple #11
0
 public int IPrimDispose()
 {
     LTDMC.dmc_board_close();
     return(0);
 }
 public void CloseComm()
 {
     LTDMC.dmc_board_close();
     LSList.Clear();
 }