Beispiel #1
0
        public int LineRel(int nRobotIndex, Coordnates nCoordnate, double dbValue, double dbAcc, double dbDec, double dbSpeed)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.LineCoordnate(nCoordnate, MovementsTypes.Rel, SpeedTypes.Use, WaitTypes.Wait, dbValue, dbAcc, dbDec, dbSpeed);

            return(nRet);
        }
Beispiel #2
0
        /// <summary>
        /// 單一關節移動(絕對位置)(角度)(輸入速度)(不等待繼續)
        /// </summary>
        /// <param name="nRobotIndex">手臂代號</param>
        /// <param name="nJoint">關節代號</param>
        /// <param name="dbDegree">絕對移動到角度值(絕對位置)</param>
        /// <param name="dbAcc">加速度比例(0-100)</param>
        /// <param name="dbDec">減速度比例(0-100)</param>
        /// <param name="dbSpeed">最大速比例(0-100)</param>
        /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
        public int MoveAbs(int nRobotIndex, Joints nJoint, double dbDegree, double dbAcc, double dbDec, double dbSpeed)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.MoveJoint(nJoint, MovementsTypes.Abs, SpeedTypes.Use, WaitTypes.Wait, dbDegree, dbAcc, dbDec, dbSpeed);

            return(1);
        }
Beispiel #3
0
        public int LinePtoPAbs(int nRobotIndex, double dbX, double dbY, double dbZ, double dbRx, double dbRy, double dbRz, double dbAcc, double dbDec, double dbSpeed)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.LinePtoP(SpeedTypes.Use, WaitTypes.Wait, dbX, dbY, dbZ, dbRx, dbRy, dbRz, dbAcc, dbDec, dbSpeed);

            return(nRet);
        }
Beispiel #4
0
        public int LineAbs(int nRobotIndex, Coordnates nCoordnate, double dbValue)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.LineCoordnate(nCoordnate, MovementsTypes.Abs, SpeedTypes.NoUse, WaitTypes.Wait, dbValue, 0, 0, 0);

            return(nRet);
        }
Beispiel #5
0
        /*
         * STDMETHOD(LineSingleRel)(LONG lDirection, DOUBLE dbPos, LONG* lRet);
         * STDMETHOD(LineSingleRelWait)(LONG lDirection, DOUBLE dbPos, LONG* lRet);
         * STDMETHOD(LineSingleRelSpeed)(LONG lDirection, DOUBLE dbPos, DOUBLE dbSpeed, DOUBLE dbAcc, DOUBLE dbDec, LONG* lRet);
         * STDMETHOD(LineSingleRelSpeedWait)(LONG lDirection, DOUBLE dbPos, DOUBLE dbSpeed, DOUBLE dbAcc, DOUBLE dbDec, LONG* lRet);
         * STDMETHOD(LineSingleAbs)(LONG lDirection, DOUBLE dbPos, LONG* lRet);
         * STDMETHOD(LineSingleAbsWait)(LONG lDirection, DOUBLE dbPos, LONG* lRet);
         * STDMETHOD(LineSingleAbsSpeed)(LONG lDirection, DOUBLE dbPos, DOUBLE dbSpeed, DOUBLE dbAcc, DOUBLE dbDec, LONG* lRet);
         * STDMETHOD(LineSingleAbsSpeedWait)(LONG lDirection, DOUBLE dbPos, DOUBLE dbSpeed, DOUBLE dbAcc, DOUBLE dbDec, LONG* lRet);
         */

        /// <summary>
        /// 單一關節Jog移動
        /// </summary>
        /// <param name="nRobotIndex">手臂代號</param>
        /// <param name="nJoint">關節代號</param>
        /// <param name="nDir">移動方向</param>
        /// <param name="dbSpeedPercentage">速度百分比</param>
        /// <returns>回傳是否成功,0:成功, 其他數字:失敗</returns>
        public int JogCoordnate(int nRobotIndex, Coordnates nCoordnate, Jog_Directions nDir, Jog_Speed nSpeed)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.JogCoordnate(nCoordnate, nDir, nSpeed);

            return(nRet);
        }
Beispiel #6
0
        /// <summary>
        /// 單一關節Jog移動停止
        /// </summary>
        /// <param name="nRobotIndex">手臂代號</param>
        /// <param name="nJoint">關節代號</param>
        /// <returns>回傳是否成功,0:成功, 其他數字:失敗</returns>
        public int JogCoordnateStop(int nRobotIndex, Coordnates nCoordnate)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.JogCoordnateStop(nCoordnate);

            return(nRet);
        }
Beispiel #7
0
        /// <summary>
        /// 對指定手臂斷線
        /// </summary>
        /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
        public int DisconnectRobot(int nRobotIndex)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.Disconnect();

            return(nRet);
        }
Beispiel #8
0
        /// <summary>
        /// 單一關節Jog移動
        /// </summary>
        /// <param name="nRobotIndex">手臂代號</param>
        /// <param name="nJoint">關節代號</param>
        /// <param name="nDir">移動方向</param>
        /// <param name="dbSpeedPercentage">速度百分比</param>
        /// <returns>回傳是否成功,0:成功, 其他數字:失敗</returns>
        public int JogJoint(int nRobotIndex, Joints nJoint, Jog_Directions nDir, Jog_Speed nSpeed)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.JogJoint(nJoint, nDir, nSpeed);

            return(nRet);

            /*
             * IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
             * double dbAcc = 0;
             * double dbDec = 0;
             * double dbSpeed = 0;
             * if (nSpeed == Jog_Speed.High)
             * {
             *  dbAcc = 10000;dbDec = 10000; dbSpeed = 30;
             * }
             *
             * else if (nSpeed == Jog_Speed.Mid)
             * { dbAcc = 10000; dbDec = 10000; dbSpeed = 20; }
             *
             * else if (nSpeed == Jog_Speed.Mid)
             * { dbAcc = 10000; dbDec = 10000; dbSpeed = 10; }
             *
             *
             * double dbValue = 0;
             * if (nDir == Jog_Directions.Plus)
             *  dbValue = 50;
             * else if (nDir == Jog_Directions.Minus)
             *  dbValue = -50;
             *
             * int nRet = IRobot.MoveSingleJoint(nJoint, MovementsTypes.Abs, UnitTypes.Degree, SpeedTypes.Use, WaitTypes.NoWait, dbValue, dbAcc, dbDec, dbSpeed);
             */

            return(nRet);
        }
Beispiel #9
0
        /// <summary>
        /// 單一關節Jog移動停止
        /// </summary>
        /// <param name="nRobotIndex">手臂代號</param>
        /// <param name="nJoint">關節代號</param>
        /// <returns>回傳是否成功,0:成功, 其他數字:失敗</returns>
        public int JogJointStop(int nRobotIndex, Joints nJoint)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.JogJointStop(nJoint);

            return(nRet);
        }
Beispiel #10
0
        /// <summary>
        /// 單一關節移動(相對位置)(徑度)(有輸入速度)(等待繼續)
        /// </summary>
        /// <param name="nRobotIndex">手臂代號</param>
        /// <param name="nJoint">關節代號</param>
        /// <param name="dbDegree">相對移動徑度值(相對位置)</param>
        /// <param name="dbAcc">移動時加速度</param>
        /// <param name="dbSpeed">移動時均速度</param>
        /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
        public int MoveJointRelRadianSpeedWait(int nRobotIndex, Joints nJoint, double dbRadian, double dbAcc, double dbDec, double dbSpeed)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.MoveJoint(nJoint, MovementsTypes.Rel, SpeedTypes.Use, WaitTypes.Wait, dbRadian, dbAcc, dbDec, dbSpeed);

            return(1);
        }
Beispiel #11
0
        /// <summary>
        /// 單一關節移動(相對位置)(徑度)(無輸入速度)(不等待繼續)
        /// </summary>
        /// <param name="nRobotIndex">手臂代號</param>
        /// <param name="nJoint">關節代號</param>
        /// <param name="dbDegree">相對移動徑度值(相對位置)</param>
        /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
        public int MoveJointRelRadian(int nRobotIndex, Joints nJoint, double dbRadian)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.MoveJoint(nJoint, MovementsTypes.Rel, SpeedTypes.NoUse, WaitTypes.NoWait, dbRadian, 0, 0, 0);

            return(1);
        }
Beispiel #12
0
        /// <summary>
        /// 單一關節移動(絕對位置)(角度)(無輸入速度)(不等待繼續)
        /// </summary>
        /// <param name="nRobotIndex">手臂代號</param>
        /// <param name="nJoint">關節代號</param>
        /// <param name="dbDegree">絕對移動到角度值(絕對位置)</param>
        /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
        public int JointAbsWait(int nRobotIndex, Joints nJoint, double dbDegree)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.MoveJoint(nJoint, MovementsTypes.Abs, SpeedTypes.NoUse, WaitTypes.Wait, dbDegree, 0, 0, 0);

            return(1);
        }
Beispiel #13
0
        /// <summary>
        /// 全部關節移動(相對位置)(角度)(有輸入速度)(等待繼續)
        /// </summary>
        /// <param name="nRobotIndex">手臂代號</param>
        /// <param name="dbJ1Degree">關節1 相對移動到角度值(相對位置)</param>
        /// <param name="dbJ2Degree">關節2 相對移動到角度值(相對位置)</param>
        /// <param name="dbJ3Degree">關節3 相對移動到角度值(相對位置)</param>
        /// <param name="dbJ4Degree">關節4 相對移動到角度值(相對位置)</param>
        /// <param name="dbJ5Degree">關節5 相對移動到角度值(相對位置)</param>
        /// <param name="dbJ6Degree">關節6 相對移動到角度值(相對位置)</param>
        /// <param name="dbAcc">移動時加速度</param>
        /// <param name="dbSpeed">移動時最大速度</param>
        /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
        public virtual int MoveAllJointRelDegreeSpeedWait(int nRobotIndex, double dbJ1Degree, double dbJ2Degree, double dbJ3Degree, double dbJ4Degree, double dbJ5Degree, double dbJ6Degree, double dbAcc, double dbDec, double dbSpeed)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.MoveAllJoint(MovementsTypes.Rel, UnitTypes.Degree, SpeedTypes.Use, WaitTypes.Wait,
                                           dbJ1Degree, dbJ2Degree, dbJ3Degree, dbJ4Degree, dbJ5Degree, dbJ6Degree, dbAcc, dbDec, dbSpeed);

            return(1);
        }
Beispiel #14
0
        /// <summary>
        /// 全部關節移動(相對位置)(徑度)(有輸入速度)(等待繼續)
        /// </summary>
        /// <param name="nRobotIndex">手臂代號</param>
        /// <param name="dbJ1Radian">關節1 相對移動到徑度值(相對位置)</param>
        /// <param name="dbJ2Radian">關節2 相對移動到徑度值(相對位置)</param>
        /// <param name="dbJ3Radian">關節3 相對移動到徑度值(相對位置)</param>
        /// <param name="dbJ4Radian">關節4 相對移動到徑度值(相對位置)</param>
        /// <param name="dbJ5Radian">關節5 相對移動到徑度值(相對位置)</param>
        /// <param name="dbJ6Radian">關節6 相對移動到徑度值(相對位置)</param>
        /// <param name="dbAcc">移動時加速度</param>
        /// <param name="dbSpeed">移動時最大速度</param>
        /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
        public virtual int MoveAllJointRelRadianSpeedWait(int nRobotIndex, double dbJ1Radian, double dbJ2Radian, double dbJ3Radian, double dbJ4Radian, double dbJ5Radian, double dbJ6Radian, double dbAcc, double dbDec, double dbSpeed)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.MoveAllJoint(MovementsTypes.Rel, UnitTypes.Radian, SpeedTypes.Use, WaitTypes.Wait,
                                           dbJ1Radian, dbJ2Radian, dbJ3Radian, dbJ4Radian, dbJ5Radian, dbJ6Radian, dbAcc, dbDec, dbSpeed);

            return(1);
        }
Beispiel #15
0
        /// <summary>
        /// PtoP(絕對位置)(無輸入速度)(等待繼續)
        /// </summary>
        /// <param name="nRobotIndex">手臂代號</param>
        /// <param name="dbX">J1絕對移動到角度值(絕對位置)</param>
        /// <param name="dbY">J2絕對移動到角度值(絕對位置)</param>
        /// <param name="dbZ">J3絕對移動到角度值(絕對位置)</param>
        /// <param name="dbRx">J4絕對移動到角度值(絕對位置)</param>
        /// <param name="dbRy">J5絕對移動到角度值(絕對位置)</param>
        /// <param name="dbRz">J6絕對移動到角度值(絕對位置)</param>
        /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
        public int MovePtoPAbs(int nRobotIndex, double dbX, double dbY, double dbZ, double dbRx, double dbRy, double dbRz)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.MovePtoP(SpeedTypes.NoUse, WaitTypes.Wait,
                                       dbX, dbY, dbZ, dbRx, dbRy, dbRz, 0, 0, 0);

            return(nRet);
        }
Beispiel #16
0
        /// <summary>
        /// 全部關節移動(絕對位置)(徑度)(無輸入速度)(等待繼續)
        /// </summary>
        /// <param name="nRobotIndex">手臂代號</param>
        /// <param name="dbJ1Radian">關節1 絕對移動到徑度值(絕對位置)</param>
        /// <param name="dbJ2Radian">關節2 絕對移動到徑度值(絕對位置)</param>
        /// <param name="dbJ3Radian">關節3 絕對移動到徑度值(絕對位置)</param>
        /// <param name="dbJ4Radian">關節4 絕對移動到徑度值(絕對位置)</param>
        /// <param name="dbJ5Radian">關節5 絕對移動到徑度值(絕對位置)</param>
        /// <param name="dbJ6Radian">關節6 絕對移動到徑度值(絕對位置)</param>
        /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
        public virtual int MoveAllJointAbsRadianWait(int nRobotIndex, double dbJ1Radian, double dbJ2Radian, double dbJ3Radian, double dbJ4Radian, double dbJ5Radian, double dbJ6Radian)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.MoveAllJoint(MovementsTypes.Abs, UnitTypes.Radian, SpeedTypes.NoUse, WaitTypes.Wait,
                                           dbJ1Radian, dbJ2Radian, dbJ3Radian, dbJ4Radian, dbJ5Radian, dbJ6Radian, 0, 0, 0);

            return(1);
        }
Beispiel #17
0
        /// <summary>
        /// 全部關節移動(絕對位置)(角度)(無輸入速度)(等待繼續)
        /// </summary>
        /// <param name="nRobotIndex">手臂代號</param>
        /// <param name="dbJ1Degree">關節1 絕對移動到角度值(絕對位置)</param>
        /// <param name="dbJ2Degree">關節2 絕對移動到角度值(絕對位置)</param>
        /// <param name="dbJ3Degree">關節3 絕對移動到角度值(絕對位置)</param>
        /// <param name="dbJ4Degree">關節4 絕對移動到角度值(絕對位置)</param>
        /// <param name="dbJ5Degree">關節5 絕對移動到角度值(絕對位置)</param>
        /// <param name="dbJ6Degree">關節6 絕對移動到角度值(絕對位置)</param>
        /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
        public virtual int MoveAllJointAbsDegreeWait(int nRobotIndex, double dbJ1Degree, double dbJ2Degree, double dbJ3Degree, double dbJ4Degree, double dbJ5Degree, double dbJ6Degree)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.MoveAllJoint(MovementsTypes.Abs, UnitTypes.Degree, SpeedTypes.NoUse, WaitTypes.Wait,
                                           dbJ1Degree, dbJ2Degree, dbJ3Degree, dbJ4Degree, dbJ5Degree, dbJ6Degree, 0, 0, 0);

            return(1);
        }
Beispiel #18
0
        /// <summary>
        /// 全關節移動(絕對位置)(角度)(有輸入速度)(不等待繼續)
        /// </summary>
        /// <param name="nRobotIndex">手臂代號</param>
        /// <param name="dbJ1Degree">J1絕對移動到角度值(絕對位置)</param>
        /// <param name="dbJ2Degree">J2絕對移動到角度值(絕對位置)</param>
        /// <param name="dbJ3Degree">J3絕對移動到角度值(絕對位置)</param>
        /// <param name="dbJ4Degree">J4絕對移動到角度值(絕對位置)</param>
        /// <param name="dbJ5Degree">J5絕對移動到角度值(絕對位置)</param>
        /// <param name="dbJ6Degree">J6絕對移動到角度值(絕對位置)</param>
        /// <param name="dbAcc">加速度比例(0-100)</param>
        /// <param name="dbDec">減速度比例(0-100)</param>
        /// <param name="dbSpeed">最大速比例(0-100)</param>
        /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
        public int JointAbs(int nRobotIndex, double dbJ1Degree, double dbJ2Degree, double dbJ3Degree, double dbJ4Degree, double dbJ5Degree, double dbJ6Degree, double dbAcc, double dbDec, double dbSpeed)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.MoveAllJoint(MovementsTypes.Abs, UnitTypes.Degree, SpeedTypes.Use, WaitTypes.NoWait,
                                           dbJ1Degree, dbJ2Degree, dbJ3Degree, dbJ4Degree, dbJ5Degree, dbJ6Degree, dbAcc, dbDec, dbSpeed);

            return(1);
        }
Beispiel #19
0
        public int Arc(int nRobotIndex, double dbMidX, double dbMidY, double dbMidZ, double dbMidRx, double dbMidRy, double dbMidRz,
                       double dbEndX, double dbEndY, double dbEndZ, double dbEndRx, double dbEndRy, double dbEndRz)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            int nRet = IRobot.Arc(SpeedTypes.NoUse, WaitTypes.Wait, dbMidX, dbMidY, dbMidZ, dbMidRx, dbMidRy, dbMidRz,
                                  dbEndX, dbEndY, dbEndZ, dbEndRx, dbEndRy, dbEndRz, 0, 0, 0);

            return(nRet);
        }
Beispiel #20
0
        /// <summary>
        /// 擷取6關節目前角度值
        /// </summary>
        /// <param name="nRobotIndex">手臂代號</param>
        /// <param name="dbJ1">第1個關節角度回傳值</param>
        /// <param name="dbJ2">第2個關節角度回傳值</param>
        /// <param name="dbJ3">第3個關節角度回傳值</param>
        /// <param name="dbJ4">第4個關節角度回傳值</param>
        /// <param name="dbJ5">第5個關節角度回傳值</param>
        /// <param name="dbJ6">第6個關節角度回傳值</param>
        /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
        public int GetJointDegree(int nRobotIndex, ref double dbJ1, ref double dbJ2, ref double dbJ3, ref double dbJ4, ref double dbJ5, ref double dbJ6)
        {
            IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
            //Type robot = m_listRobotPluginTypes[nRobotIndex];
            //IRobotMotion.IRobotMotion IRobot = (IRobotMotion.IRobotMotion)Activator.CreateInstance(robot);

            IRobot.GetJointDegree(ref dbJ1, ref dbJ2, ref dbJ3, ref dbJ4, ref dbJ5, ref dbJ6);

            //  foreach (Type type in pluginTypes)
            //  {
            //      IPlugin.IPlugin plugin = (IPlugin.IPlugin)Activator.CreateInstance(type);
            //      MessageBox.Show(plugin.Name);
            //  }

            return(1);
        }
Beispiel #21
0
 /// <summary>
 /// 減速停止所有關節運動(補間運動時使用)
 /// </summary>
 /// <param name="nRobotIndex">手臂代號</param>
 /// <param name="dbDec">減速度值</param>
 /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
 public int StopMotionForLine(int nRobotIndex, double dbDec)
 {
     IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
     IRobot.StopMotionForLine(dbDec);
     return(1);
 }
Beispiel #22
0
 /// <summary>
 /// 擷取6關節目前加速度值
 /// </summary>
 /// <param name="nRobotIndex">手臂代號</param>
 /// <param name="dbJ1">第1個關節加速度回傳值</param>
 /// <param name="dbJ2">第2個關節加速度回傳值</param>
 /// <param name="dbJ3">第3個關節加速度回傳值</param>
 /// <param name="dbJ4">第4個關節加速度回傳值</param>
 /// <param name="dbJ5">第5個關節加速度回傳值</param>
 /// <param name="dbJ6">第6個關節加速度回傳值</param>
 /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
 public int GetJointAccValue(int nRobotIndex, ref double dbJ1, ref double dbJ2, ref double dbJ3, ref double dbJ4, ref double dbJ5, ref double dbJ6)
 {
     IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
     IRobot.GetJointAccValue(ref dbJ1, ref dbJ2, ref dbJ3, ref dbJ4, ref dbJ5, ref dbJ6);
     return(1);
 }
Beispiel #23
0
        /// <summary>
        /// 初始化此模組
        /// </summary>
        /// <param name="strSettingFile">設定擋路徑</param>
        /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
        public void Init(string strSettingFile)
        {
            FileOperation.IniFile iniFile;
            iniFile = new IniFile(strSettingFile);

            //手臂總數
            m_nRobots = iniFile.ReadInteger("Robots", "total_num", 0);

            //    Type pluginType = typeof(IRobotMotion.IRobotMotion);

            m_listRobots = new List <IRobotMotion.IRobotMotion>();

            for (int n = 0; n < m_nRobots; n++)
            {
                string strSection = "Robot" + Convert.ToString(n);
                string strType    = iniFile.ReadString(strSection, "type", "");
                Type   pluginType = typeof(IRobotMotion.IRobotMotion);

                switch (strType)
                {
                case "Toshiba6":
                    string       strToshiba6DllName = System.IO.Directory.GetCurrentDirectory() + "\\Toshiba6Robot.dll";
                    int          nToshiba6Id        = iniFile.ReadInteger(strSection, "id", 0);
                    string       strToshiba6IP      = iniFile.ReadString(strSection, "robot_ip", "");
                    int          nToshiba6Port0     = iniFile.ReadInteger(strSection, "robot_port0", 0);
                    int          nToshiba6Port1     = iniFile.ReadInteger(strSection, "robot_port1", 0);
                    string       strToshiba6Program = iniFile.ReadString(strSection, "robot_program", "");
                    int          nToshiba6OVRD      = iniFile.ReadInteger(strSection, "robot_init_ovrd", 10);
                    AssemblyName anToshiba6         = AssemblyName.GetAssemblyName(strToshiba6DllName);
                    Assembly     assemblyToshiba6   = Assembly.Load(anToshiba6);
                    //Type type = assemblyToshiba6.GetType();
                    // IRobotMotion.IRobotMotion IRobot = (IRobotMotion.IRobotMotion)Activator.CreateInstance(type);

                    //Type tt = type.GetInterface(pluginType.FullName);
                    // IRobotMotion.IRobotMotion IRobot = (IRobotMotion.IRobotMotion)Activator.CreateInstance(type);

                    Type[] typesToshiba6 = assemblyToshiba6.GetTypes();
                    foreach (Type type in typesToshiba6)
                    {
                        //如果為純interface 或 抽象型別, 則跳過此dll
                        if (type.IsInterface || type.IsAbstract)
                        {
                            continue;
                        }
                        else if (type.GetInterface(pluginType.FullName) != null)
                        {
                            IRobotMotion.IRobotMotion IToshiba6Robot = (IRobotMotion.IRobotMotion)Activator.CreateInstance(type);
                            ((Toshiba6Robot.Toshiba6)IToshiba6Robot).m_nId             = nToshiba6Id;
                            ((Toshiba6Robot.Toshiba6)IToshiba6Robot).m_strRobotIP      = strToshiba6IP;
                            ((Toshiba6Robot.Toshiba6)IToshiba6Robot).m_nRobotPort0     = nToshiba6Port0;
                            ((Toshiba6Robot.Toshiba6)IToshiba6Robot).m_nRobotPort1     = nToshiba6Port1;
                            ((Toshiba6Robot.Toshiba6)IToshiba6Robot).m_strRobotProgram = strToshiba6Program;
                            ((Toshiba6Robot.Toshiba6)IToshiba6Robot).m_nRobotInitOVRD  = nToshiba6OVRD;
                            m_listRobots.Add(IToshiba6Robot);
                        }
                    }

                    //  Type type = assemblyToshiba6.GetType();
                    //  IRobotMotion.IRobotMotion IToshiba6Robot = (IRobotMotion.IRobotMotion)Activator.CreateInstance(type);
                    //  ((Toshiba6Robot.Toshiba6)IToshiba6Robot).m_nId = nToshiba6Id;
                    //  ((Toshiba6Robot.Toshiba6)IToshiba6Robot).m_strRobotIP = strToshiba6IP;
                    ////  ((Toshiba6Robot.Toshiba6)IToshiba6Robot).m_nRobotPort = nToshiba6Port;
                    //  m_listRobots.Add(IToshiba6Robot);
                    break;

                case "Toshiba4":
                    string       strToshiba4DllName = System.IO.Directory.GetCurrentDirectory() + "\\Toshiba4Robot.dll";
                    int          nToshiba4Id        = iniFile.ReadInteger(strSection, "id", 0);
                    string       strToshiba4IP      = iniFile.ReadString(strSection, "robot_ip", "");
                    int          nToshiba4Port0     = iniFile.ReadInteger(strSection, "robot_port0", 0);
                    int          nToshiba4Port1     = iniFile.ReadInteger(strSection, "robot_port1", 0);
                    string       strToshiba4Program = iniFile.ReadString(strSection, "robot_program", "");
                    int          nToshiba4OVRD      = iniFile.ReadInteger(strSection, "robot_init_ovrd", 10);
                    AssemblyName anToshiba4         = AssemblyName.GetAssemblyName(strToshiba4DllName);
                    Assembly     assemblyToshiba4   = Assembly.Load(anToshiba4);

                    Type[] typesToshiba4 = assemblyToshiba4.GetTypes();
                    foreach (Type type in typesToshiba4)
                    {
                        //如果為純interface 或 抽象型別, 則跳過此dll
                        if (type.IsInterface || type.IsAbstract)
                        {
                            continue;
                        }
                        else if (type.GetInterface(pluginType.FullName) != null)
                        {
                            IRobotMotion.IRobotMotion IToshiba4Robot = (IRobotMotion.IRobotMotion)Activator.CreateInstance(type);
                            ((Toshiba4Robot.Toshiba4)IToshiba4Robot).m_nId             = nToshiba4Id;
                            ((Toshiba4Robot.Toshiba4)IToshiba4Robot).m_strRobotIP      = strToshiba4IP;
                            ((Toshiba4Robot.Toshiba4)IToshiba4Robot).m_nRobotPort0     = nToshiba4Port0;
                            ((Toshiba4Robot.Toshiba4)IToshiba4Robot).m_nRobotPort1     = nToshiba4Port1;
                            ((Toshiba4Robot.Toshiba4)IToshiba4Robot).m_strRobotProgram = strToshiba4Program;
                            ((Toshiba4Robot.Toshiba4)IToshiba4Robot).m_nRobotInitOVRD  = nToshiba4OVRD;
                            m_listRobots.Add(IToshiba4Robot);
                        }
                    }


                    break;

                case "Epson6":
                    string strEpson6DllName   = System.IO.Directory.GetCurrentDirectory() + "\\Epson6Robot.dll";
                    int    nEpson6Id          = iniFile.ReadInteger(strSection, "id", 0);
                    string strEpson6GetInfoIP = iniFile.ReadString(strSection, "get_info_ip", "");
                    int    nEpson6GetInfoPort = iniFile.ReadInteger(strSection, "get_info_port", 0);
                    string strEpson6SendCmdIP = iniFile.ReadString(strSection, "send_cmd_ip", "");
                    int    nEpson6SendCmdPort = iniFile.ReadInteger(strSection, "send_cmd_port", 0);

                    AssemblyName anEpson6       = AssemblyName.GetAssemblyName(strEpson6DllName);
                    Assembly     assemblyEpson6 = Assembly.Load(anEpson6);
                    //Type type = assemblyToshiba6.GetType();
                    // IRobotMotion.IRobotMotion IRobot = (IRobotMotion.IRobotMotion)Activator.CreateInstance(type);

                    //Type tt = type.GetInterface(pluginType.FullName);
                    // IRobotMotion.IRobotMotion IRobot = (IRobotMotion.IRobotMotion)Activator.CreateInstance(type);

                    Type[] typesEpson6 = assemblyEpson6.GetTypes();
                    foreach (Type type in typesEpson6)
                    {
                        //如果為純interface 或 抽象型別, 則跳過此dll
                        if (type.IsInterface || type.IsAbstract)
                        {
                            continue;
                        }
                        else if (type.GetInterface(pluginType.FullName) != null)
                        {
                            IRobotMotion.IRobotMotion IEpson6Robot = (IRobotMotion.IRobotMotion)Activator.CreateInstance(type);
                            ((Epson6Robot.Epson6)IEpson6Robot).m_nId          = nEpson6Id;
                            ((Epson6Robot.Epson6)IEpson6Robot).m_strGetInfoIP = strEpson6GetInfoIP;
                            ((Epson6Robot.Epson6)IEpson6Robot).m_nGetInfoPort = nEpson6GetInfoPort;
                            ((Epson6Robot.Epson6)IEpson6Robot).m_strSendCmdIP = strEpson6SendCmdIP;
                            ((Epson6Robot.Epson6)IEpson6Robot).m_nSendCmdPort = nEpson6SendCmdPort;
                            m_listRobots.Add(IEpson6Robot);
                        }
                    }

                    //  Type type = assemblyToshiba6.GetType();
                    //  IRobotMotion.IRobotMotion IToshiba6Robot = (IRobotMotion.IRobotMotion)Activator.CreateInstance(type);
                    //  ((Toshiba6Robot.Toshiba6)IToshiba6Robot).m_nId = nToshiba6Id;
                    //  ((Toshiba6Robot.Toshiba6)IToshiba6Robot).m_strRobotIP = strToshiba6IP;
                    ////  ((Toshiba6Robot.Toshiba6)IToshiba6Robot).m_nRobotPort = nToshiba6Port;
                    //  m_listRobots.Add(IToshiba6Robot);

                    break;

                case "UR":
                    string strURDllName    = System.IO.Directory.GetCurrentDirectory() + "\\URRobot.dll";
                    int    nURId           = iniFile.ReadInteger(strSection, "id", 0);
                    string strURIP         = iniFile.ReadString(strSection, "robot_ip", "");
                    int    nURRealTimePort = iniFile.ReadInteger(strSection, "robot_real_time_port", 0);
                    int    nPCListenPort   = iniFile.ReadInteger(strSection, "pc_listen_port", 0);

                    AssemblyName anUR       = AssemblyName.GetAssemblyName(strURDllName);
                    Assembly     assemblyUR = Assembly.Load(anUR);


                    Type[] typesUR = assemblyUR.GetTypes();
                    foreach (Type type in typesUR)
                    {
                        //如果為純interface 或 抽象型別, 則跳過此dll
                        if (type.IsInterface || type.IsAbstract)
                        {
                            continue;
                        }
                        else if (type.GetInterface(pluginType.FullName) != null)
                        {
                            IRobotMotion.IRobotMotion IURRobot = (IRobotMotion.IRobotMotion)Activator.CreateInstance(type);
                            ((URRobot.URRobot)IURRobot).m_nId                = nURId;
                            ((URRobot.URRobot)IURRobot).m_strRobotIP         = strURIP;
                            ((URRobot.URRobot)IURRobot).m_nRobotRealTimePort = nURRealTimePort;
                            ((URRobot.URRobot)IURRobot).m_nPCListenPort      = nPCListenPort;
                            m_listRobots.Add(IURRobot);
                        }
                    }


                    //IRobotMotion.IRobotMotion IURRobot = (IRobotMotion.IRobotMotion)Activator.CreateInstance(assemblyUR.GetType());
                    // ((URRobot.URRobot)IURRobot).m_nId = nURId;
                    //((URRobot.URRobot)IURRobot).m_strRobotIP = strURIP;
                    //((URRobot.URRobot)IURRobot).m_nRobotRealTimePort = nURRealTimePort;
                    // ((URRobot.URRobot)IURRobot).m_nPCListenPort = nPCListenPort;
                    // m_listRobots.Add(IURRobot);
                    break;
                }
            }



            /*
             * //1.取得dll檔案名稱
             * string[] dllFileNames = null;
             * // dllFileNames = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.dll");
             * dllFileNames = Directory.GetFiles(System.IO.Directory.GetCurrentDirectory(), "*.dll");
             * string str = this.GetType().Assembly.Location;
             * //2.取得Assembly
             * List<Assembly> assemblies = new List<Assembly>(dllFileNames.Length);
             * foreach (string dllFile in dllFileNames)
             * {
             *  AssemblyName an = AssemblyName.GetAssemblyName(dllFile);
             *  Assembly assembly = Assembly.Load(an);
             *  assemblies.Add(assembly);
             * }
             *
             * //3.取得插件型別
             * //3.取得所有Dll內的指定型別 (IRobotMotion)
             * Type pluginType = typeof(IRobotMotion.IRobotMotion);
             * m_listRobotPluginTypes = new List<Type>();
             *
             * m_listRobots = new List<IRobotMotion.IRobotMotion>();
             * foreach (Assembly assembly in assemblies)
             * {
             *  if (assembly == null)
             *      continue;
             *  Type[] types = assembly.GetTypes();
             *  foreach (Type type in types)
             *  {
             *    //  Type tt = type.GetInterface(pluginType.FullName);
             *
             *      //如果為純interface 或 抽象型別, 則跳過此dll
             *      if (type.IsInterface || type.IsAbstract)
             *          continue;
             *      else if (type.GetInterface(pluginType.FullName) != null)
             *      {
             *          m_listRobotPluginTypes.Add(type);
             *
             *          IRobotMotion.IRobotMotion IRobot = (IRobotMotion.IRobotMotion)Activator.CreateInstance(type);
             *          m_listRobots.Add(IRobot);
             *
             *      }
             *  }
             * }
             */
        }
Beispiel #24
0
 /// <summary>
 /// 擷取 笛卡爾座標系位置值
 /// </summary>
 /// <param name="nRobotIndex">手臂代號</param>
 /// <param name="dbX">x方向回傳值(mm)</param>
 /// <param name="dbY">y方向回傳值(mm)</param>
 /// <param name="dbZ">z方向回傳值(mm)</param>
 /// <param name="dbRx">Rx方向回傳值(mm)</param>
 /// <param name="dbRy">Ry方向回傳值(mm)</param>
 /// <param name="dbRz">Rz方向回傳值(mm)</param>
 /// <returns>回傳是否成功,1:成功,-1:失敗</returns>
 public int GetWorldPos(int nRobotIndex, ref double dbX, ref double dbY, ref double dbZ, ref double dbRx, ref double dbRy, ref double dbRz)
 {
     IRobotMotion.IRobotMotion IRobot = m_listRobots[nRobotIndex];
     IRobot.GetWorldPos(ref dbX, ref dbY, ref dbZ, ref dbRx, ref dbRy, ref dbRz);
     return(1);
 }