/// <summary>
        ///打开指定EZD文件夹
        /// </summary>
        /// <MethodName>LoadEzdFile</MethodName>
        /// <param name="strFile">欲打开EZD文件名</param>
        /// <param name="bDialog">false 手动选择 true 自动加载</param>
        /// <returns>true-成功 fase-失败</returns>
        public static bool LoadEzdFile(ref string strFile, bool bDialog = false)
        {
            if (!mIsInitLaser)
            {
                MessageBox.Show("激光器没有初始化");
                return(false);
            }
            if (bDialog)
            {
                OpenFileDialog openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
                openFileDialog1.Filter = "模板文件(*.ezd)|*.ezd";
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    strFile = openFileDialog1.FileName;
                }
                else
                {
                    return(false);
                }
            }
            LmcErrCode Ret = LMC1_LOADEZDFILE(strFile);

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                mMarkEzdFile = strFile;
                return(true);
            }
            else
            {
                mLastError = Ret;
                return(false);
            }
        }
        /// <summary>
        /// 标刻
        /// </summary>
        /// <MethodName>Mark</MethodName>
        /// <param name="bFlay">false-静止打标</param>
        /// <returns>true-成功 fase-失败		</returns>
        public static bool Mark(bool bFlay = false)
        {
            if (!mIsInitLaser)
            {
                MessageBox.Show("激光器没有初始化");
                return(false);
            }
            int nFly = 0;

            if (bFlay)
            {
                nFly = 1;
            }
            LmcErrCode Ret = LMC1_MARK(nFly);

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                return(true);
            }
            else
            {
                mLastError = Ret;
                return(false);
            }
        }
        /// <summary>
        ///根据笔号获取所有
        /// </summary>
        /// <methodName>GetPenParam</methodName>
        /// <param name="nPenNo">要设置的笔号(0-255)</param>
        /// <param name="nMarkLoop">加工次数</param>
        /// <param name="dMarkSpeed">标刻次数mm/s</param>
        /// <param name="dPowerRatio">功率百分比(0-100%)</param>
        /// <param name="dCurrent">电流A</param>
        /// <param name="nFreq">频率HZ</param>
        /// <param name="dQPulseWidth">Q脉冲宽度us</param>
        /// <param name="nStartTC">开始延时us</param>
        /// <param name="nLaserOffTC">激光关闭延时us</param>
        /// <param name="nEndTC">结束延时us</param>
        /// <param name="nPolyTC">拐角延时us</param>
        /// <param name="dJumpSpeed">跳转速度mm/s</param>
        /// <param name="nJumpPosTC">跳转位置延时us</param>
        /// <param name="nJumpDistTC">跳转距离延时us</param>
        /// <param name="dEndComp">末点补偿mm</param>
        /// <param name="dAccDist">加速距离mm</param>
        /// <param name="dPointTime">打点延时 ms</param>
        /// <param name="bPulsePointMode">脉冲点模式</param>
        /// <param name="nPulseNum">脉冲点数目</param>
        /// <param name="dFlySpeed">流水线速度</param>
        /// <returns>true 成功 false 失败</returns>
        public static bool GetPenParam(int nPenNo,
                                       ref int nMarkLoop,
                                       ref double dMarkSpeed,
                                       ref double dPowerRatio,
                                       ref double dCurrent,
                                       ref int nFreq,
                                       ref double dQPulseWidth,
                                       ref int nStartTC,
                                       ref int nLaserOffTC,
                                       ref int nEndTC,
                                       ref int nPolyTC,
                                       ref double dJumpSpeed,
                                       ref int nJumpPosTC,
                                       ref int nJumpDistTC,
                                       ref double dEndComp,
                                       ref double dAccDist,
                                       ref double dPointTime,
                                       ref bool bPulsePointMode,
                                       ref int nPulseNum,
                                       ref double dFlySpeed)
        {
            LmcErrCode Ret = lmc1_GetPenParam(nPenNo, ref nMarkLoop, //加工次数
                                              ref dMarkSpeed,        //标刻次数mm/s
                                              ref dPowerRatio,       //功率百分比(0-100%)
                                              ref dCurrent,          //电流A
                                              ref nFreq,             //频率HZ
                                              ref dQPulseWidth,      //Q脉冲宽度us
                                              ref nStartTC,          //开始延时us
                                              ref nLaserOffTC,       //激光关闭延时us
                                              ref nEndTC,            //结束延时us
                                              ref nPolyTC,           //拐角延时us   //
                                              ref dJumpSpeed,        //跳转速度mm/s
                                              ref nJumpPosTC,        //跳转位置延时us
                                              ref nJumpDistTC,       //跳转距离延时us
                                              ref dEndComp,          //末点补偿mm
                                              ref dAccDist,          //加速距离mm
                                              ref dPointTime,        //打点延时 ms
                                              ref bPulsePointMode,   //脉冲点模式
                                              ref nPulseNum,         //脉冲点数目
                                              ref dFlySpeed);        //流水线速度

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                return(true);
            }
            else
            {
                mLastError = Ret;
                return(false);
            }
        }
        /// <summary>
        ///移动扩展轴
        /// </summary>
        /// <methodName>AxisMoveTo</methodName>
        /// <param name="axis">轴号</param>
        /// <param name="GoalPos">目标位置</param>
        /// <returns>true 成功 false 失败</returns>
        public static bool AxisMoveTo(int axis, double GoalPos)
        {
            LmcErrCode Ret = lmc1_AxisMoveTo(axis, GoalPos);

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                return(true);
            }
            else
            {
                mLastError = Ret;
                return(false);
            }
        }
        /// <summary>
        ///根据对象名字移动对象
        /// </summary>
        /// <methodName>MoveEnt</methodName>
        /// <param name="pEntName">对象名</param>
        /// <param name="dMovex">移动X相对距离</param>
        /// <param name="dMovey">移动Y相对距离</param>
        /// <returns>true 成功 false 失败</returns>
        public static bool MoveEnt(string pEntName, double dMovex, double dMovey)
        {
            LmcErrCode Ret = LMC1_MOVEENT(pEntName, dMovex, dMovey);

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                return(true);
            }
            else
            {
                mLastError = Ret;
                return(false);
            }
        }
        /// <summary>
        ///根据名称获取实体位置和大小
        /// </summary>
        /// <methodName>GetEntSize</methodName>
        /// <param name="strEntName">对象的名字</param>
        /// <param name="dMinx">最小X</param>
        /// <param name="dMiny">最小Y</param>
        /// <param name="dMaxx">最大X</param>
        /// <param name="dMaxy">最大Y</param>
        /// <param name="dZ"></param>
        /// <returns>true 成功 false 失败</returns>
        public static bool GetEntSize(string strEntName, ref double dMinx, ref double dMiny, ref double dMaxx, ref double dMaxy, ref double dZ)
        {
            LmcErrCode Ret = LMC1_GETENTSIZE(strEntName, ref dMinx, ref dMiny, ref dMaxx, ref dMaxy, ref dZ);

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                return(true);
            }
            else
            {
                mLastError = Ret;
                return(false);
            }
        }
        /// <summary>
        ///根据对象名字旋转对象
        /// </summary>
        /// <methodName>RotateEnt</methodName>
        /// <param name="strEntName">对象名</param>
        /// <param name="dCenx">旋转中心X</param>
        /// <param name="dCeny">旋转中心Y</param>
        /// <param name="dAngle">旋转角度(弧度)</param>
        /// <returns>true 成功 false 失败</returns>
        public static bool RotateEnt(string strEntName, double dCenx, double dCeny, double dAngle)
        {
            LmcErrCode Ret = LMC1_ROTATEENT(strEntName, dCenx, dCeny, dAngle);

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                return(true);
            }
            else
            {
                mLastError = Ret;
                return(false);
            }
        }
        /// <summary>
        ///根据索引设置对象名字
        /// </summary>
        /// <methodName>SetEntityName</methodName>
        /// <param name="nEntityIndex">对象索引</param>
        /// <param name="strEntName">对象名字</param>
        /// <returns>true 成功 false 失败</returns>
        public static bool SetEntityName(int nEntityIndex, string strEntName)
        {
            LmcErrCode Ret = LMC1_SETENTITYNAME(nEntityIndex, strEntName);

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                SaveEntLibToFile();
                return(true);
            }
            else
            {
                mLastError = Ret;
                return(false);
            }
        }
 /// <summary>
 ///关闭金橙子板卡
 /// </summary>
 /// <MethodName>Close</MethodName>
 public static void Close()
 {
     if (mIsInitLaser)
     {
         LmcErrCode Ret = LMC1_CLOSE();
         if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
         {
             mIsInitLaser = false;
             return;
         }
         else
         {
             mLastError = Ret;
             return;
         }
     }
 }
        /// <summary>
        ///根据索引获取当前文本对象名字
        /// </summary>
        /// <methodName>GetEntityName</methodName>
        /// <param name="nEntityIndex">nEntityIndex 对象次序</param>
        /// <param name="strEntName">strEntName 对象名字</param>
        /// <returns>true 成功 false 失败</returns>
        public static bool GetEntityName(int nEntityIndex, ref string strEntName)
        {
            char[]     chEnt = new char[256];
            LmcErrCode Ret   = LMC1_GETENTITYNAME(nEntityIndex, chEnt);

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                strEntName = new string(chEnt);
                strEntName = strEntName.Replace(new String(new Char[] { '\0' }), "");
                return(true);
            }
            else
            {
                mLastError = Ret;
                return(false);
            }
        }
        /// <summary>
        ///设置输出IO信号
        /// </summary>
        /// <methodName>SetOutPort</methodName>
        /// <param name="nPort">端口号</param>
        /// <param name="bState">状态值</param>
        /// <returns>true 成功 false 失败</returns>
        public static bool SetOutPort(int nPort, bool bState)
        {
            if (!mIsInitLaser)
            {
                MessageBox.Show("激光器没有初始化");
                return(false);
            }
            if (nPort < 0 || nPort > 15)
            {
                return(false);
            }
            int        nState = 0;
            LmcErrCode Ret    = LMC1_GETOUTPORT(ref nState);

            if (LmcErrCode.LMC1_ERR_SUCCESS != Ret)
            {
                mLastError = Ret;
                return(false);
            }

            int dbuff = 0;

            if (bState)
            {
                dbuff   = 0x0001 << nPort;
                nState |= dbuff;
            }
            else
            {
                dbuff   = ~(0x0001 << nPort);
                nState &= dbuff;
            }

            Ret = LMC1_WRITEPORT(nState);
            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                return(true);
            }
            else
            {
                mLastError = Ret;
                return(false);
            }
            return(true);
        }
        /// <summary>
        ///JCZ接口初始化
        /// </summary>
        /// <MethodName>InitLaser</MethodName>
        /// <param name="hwnd">hwnd 控件句柄</param>
        /// <returns>true 成功 false 失败</returns>
        public static bool InitLaser(IntPtr hwnd)
        {
            mIsInitLaser = false;
            mPtr         = hwnd;
            string     strEzCadPath = Application.StartupPath + "\\";
            LmcErrCode Ret          = LMC1_INITIAL(strEzCadPath, 0, hwnd);

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                mIsInitLaser = true;
                return(true);
            }
            else
            {
                mLastError = Ret;
                return(false);
            }
        }
        /// <summary>
        ///改变对象名字
        /// </summary>
        /// <methodName>ChangeTextByName</methodName>
        /// <param name="strEntName">模板中对象名字</param>
        /// <param name="strText">改变对象的目标文字</param>
        /// <returns>true-成功 fase-失败s</returns>
        public static bool ChangeTextByName(string strEntName, string strText)
        {
            if (!mIsInitLaser)
            {
                MessageBox.Show("激光器没有初始化");
                return(false);
            }
            LmcErrCode Ret = LMC1_CHANGETEXTBYNAME(strEntName, strText);

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                return(true);
            }
            else
            {
                mLastError = Ret;
                return(false);
            }
        }
        /// <summary>
        ///定时器事件,触发红光
        /// </summary>
        /// <methodName>StartRedLight</methodName>
        /// <param name="source"></param>
        /// <param name="e"></param>
        /// <returns>true 成功 false 失败</returns>
        private static void StartRedLight(Object source, ElapsedEventArgs e)
        {
            if (!mIsInitLaser)
            {
                mLastError = LmcErrCode.LMC1_ERR_NOINITIAL;
                return;
            }
            LmcErrCode Ret = LMC1_REDLIGHTMARK();

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                return;
            }
            else
            {
                mLastError = Ret;
                return;
            }
        }
        /// <summary>
        ///弹出设置参数对话框
        /// </summary>
        /// <methodName>SetConfigForm</methodName>
        public static void SetConfigForm()
        {
            if (!mIsInitLaser)
            {
                MessageBox.Show("激光器没有初始化");
                return;
            }
            LmcErrCode Ret = LMC1_SETDEVCFG();

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                return;
            }
            else
            {
                mLastError = Ret;
                return;
            }
        }
        /// <summary>
        ///删除对象
        /// </summary>
        /// <methodName>DeleteEnt</methodName>
        /// <param name="strEntName">对象名</param>
        /// <returns>true 成功 false 失败</returns>
        private static bool DeleteEnt(string strEntName)
        {
            if (!mIsInitLaser)
            {
                MessageBox.Show("激光器没有初始化");
                return(false);
            }
            LmcErrCode Ret = lmc1_DeleteEnt(strEntName);

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                return(true);
            }
            else
            {
                mLastError = Ret;
                return(false);
            }
        }
        /// <summary>
        ///停止标刻
        /// </summary>
        /// <MethodName>StopMark</MethodName>
        /// <returns>true-成功 fase-失败s</returns>
        public static bool StopMark()
        {
            if (!mIsInitLaser)
            {
                MessageBox.Show("激光器没有初始化");
                return(true);
            }
            LmcErrCode Ret = LMC1_STOPMARK();

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                return(true);
            }
            else
            {
                mLastError = Ret;
                return(false);
            }
        }
        /// <summary>
        ///保存模板
        /// </summary>
        /// <methodName>SaveEntLibToFile</methodName>
        /// <param name="filename">要保存模板名</param>
        /// <returns>true 成功 false 失败</returns>
        public static bool SaveEntLibToFile(string fileName = null)
        {
            if (!mIsInitLaser)
            {
                mLastError = LmcErrCode.LMC1_ERR_NOINITIAL;
                return(false);
            }
            if (fileName == null)
            {
                fileName = mMarkEzdFile;
            }
            LmcErrCode Ret = lmc1_SaveEntLibToFile(fileName);

            if (LmcErrCode.LMC1_ERR_SUCCESS == Ret)
            {
                return(true);
            }
            else
            {
                mLastError = Ret;
                return(false);
            }
        }
        /// <summary>
        ///获取输入IO信号
        /// </summary>
        /// <methodName>ReadPort</methodName>
        /// <param name="nPort">输入端口值</param>
        /// <returns>true-成功 fase-失败</returns>
        public static bool ReadPort(int nPort)
        {
            if (!mIsInitLaser)
            {
                MessageBox.Show("激光器没有初始化");
                return(false);
            }
            int        nState = 0;
            LmcErrCode Ret    = LMC1_READPORT(ref nState);

            if (LmcErrCode.LMC1_ERR_SUCCESS != Ret)
            {
                mLastError = Ret;
                return(false);
            }
            if (((nState >> nPort) & 0x01) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }