RtnCode.cs 3.9 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JAKA
{
    /// <summary>
    /// 接口调用返回值
    /// </summary>
    internal class RtnCode
    {
        /// <summary>
        /// 调用成功
        /// </summary>
        public const int ERR_SUCC = 0;
        /// <summary>
        /// 异常调用,调用接口异常,控制器不支持
        /// </summary>
        public const int ERR_FUCTION_CALL_ERROR = 2;
        /// <summary>
        /// 无效的控制句柄
        /// </summary>
        public const int ERR_INVALID_HANDLER = -1;
        /// <summary>
        /// 无效的参数
        /// </summary>
        public const int ERR_INVALID_PARAMETER = -2;
        /// <summary>
        /// 通信连接错误
        /// </summary>
        public const int ERR_COMMUNICATION_ERR = -3;
        /// <summary>
        /// 逆解失败
        /// </summary>
        public const int ERR_KINE_INVERSE_ERR = -4;
        /// <summary>
        /// 急停开关被按下
        /// </summary>
        public const int ERR_EMERGENCY_PRESSED = -5;
        /// <summary>
        /// 机器人未上电
        /// </summary>
        public const int ERR_NOT_POWERED = -6;
        /// <summary>
        /// 机器人未使能
        /// </summary>
        public const int ERR_NOT_ENABLED = -7;
        /// <summary>
        /// 机器人没有进入 servo 模式
        /// </summary>
        public const int ERR_DISABLE_SERVOMODE = -8;
        /// <summary>
        /// 机器人没有关闭使能
        /// </summary>
        public const int ERR_NOT_OFF_ENABLE = -9;
        /// <summary>
        /// 程序正在运行,不允许操作
        /// </summary>
        public const int ERR_PROGRAM_IS_RUNNING = -10;
        /// <summary>
        /// 无法打开文件,文件不存在
        /// </summary>
        public const int ERR_CANNOT_OPEN_FILE = -11;
        /// <summary>
        /// 获取编码含义
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public static string GetStrByCode(int code)
        {
            string str = "";
            switch (code)
            {
                case ERR_SUCC:
                    str = "调用成功";
                    break;
                case ERR_FUCTION_CALL_ERROR:
                    str = "调用接口异常,控制器不支持";
                    break;
                case ERR_INVALID_HANDLER:
                    str = "无效的控制句柄";
                    break;
                case ERR_INVALID_PARAMETER:
                    str = "无效的参数";
                    break;
                case ERR_COMMUNICATION_ERR:
                    str = "通信连接错误";
                    break;
                case ERR_KINE_INVERSE_ERR:
                    str = "逆解失败";
                    break;
                case ERR_EMERGENCY_PRESSED:
                    str = "急停开关被按下";
                    break;
                case ERR_NOT_POWERED:
                    str = "机器人未上电";
                    break;
                case ERR_NOT_ENABLED:
                    str = "机器人未使能";
                    break;
                case ERR_DISABLE_SERVOMODE:
                    str = "机器人没有进入 servo 模式";
                    break;
                case ERR_NOT_OFF_ENABLE:
                    str = "机器人没有关闭使能";
                    break;
                case ERR_PROGRAM_IS_RUNNING:
                    str = "程序正在运行,不允许操作";
                    break;
                case ERR_CANNOT_OPEN_FILE:
                    str = "无法打开文件,文件不存在";
                    break;
                default:
                    str = $"不存在的接口调用返回值:{code}";
                    break;
            }
            return str;
        }
    }
}