public bool IsMoveDone(short sAxis)
 {
     lock (lockObj)
     {
         return(Dmc1000.d1000_check_done(sAxis) == 0 ? false : true);
     }
 }
 public bool StartSearchHome(short sAxis, double dAcc, double dDec, double dHomeSpd)
 {
     lock (lockObj)
     {
         Dmc1000.d1000_home_move(sAxis, 0, (int)dHomeSpd, 0);
     }
     return(true);
 }
 public bool  SetCommandPos(short sAxis, double dPos)
 {
     lock (lockObj)
     {
         Dmc1000.d1000_set_command_pos(sAxis, dPos);
         return(true);
     }
 }
 public double GetVel(short sAxis)
 {
     if (Enum.IsDefined(typeof(DefaultAxis), sAxis))
     {
         lock (lockObj)
         {
             return(Dmc1000.d1000_get_speed((int)sAxis));
         }
     }
     else
     {
         return(0.0);
     }
 }
 public bool SetPulseMode(short sAxis, PulseMode plm)
 {
     lock (lockObj)
     {
         if (plm == PulseMode.PLDI)
         {
             Dmc1000.d1000_set_pls_outmode((ushort)sAxis, 0);
         }
         else
         {
             Dmc1000.d1000_set_pls_outmode((ushort)sAxis, 4);
         }
     }
     return(true);
 }
 public bool AbsPosMove(short sAxis, double dAcc, double dDec, double dSpeed, double pos)
 {
     if (Enum.IsDefined(typeof(DefaultAxis), sAxis))
     {
         lock (lockObj)
         {
             Dmc1000.d1000_start_ta_move(sAxis, (int)pos, 0, (int)dSpeed, 0);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public bool SetAxisPos(short sAxis, double dPos)
 {
     if (Enum.IsDefined(typeof(DefaultAxis), sAxis))
     {
         lock (lockObj)
         {
             Dmc1000.d1000_set_command_pos(sAxis, dPos);
             return(true);
         }
     }
     else
     {
         return(false);
     }
 }
 public bool JobMove(short sAxis, double dAcc, double dDec, double dVel)
 {
     if (Enum.IsDefined(typeof(DefaultAxis), sAxis))
     {
         lock (lockObj)
         {
             Dmc1000.d1000_start_tv_move((int)sAxis, 0, (int)dVel, 0);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public bool SetVel(short sAxis, double dVel)
 {
     lock (lockObj)
     {
         if (Enum.IsDefined(typeof(DefaultAxis), sAxis))
         {
             Dmc1000.d1000_change_speed((ushort)sAxis, (int)dVel);
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
 public bool SetOutBit(int iBit, bool bOn)
 {
     if (iBit < 128 && iBit > -1)
     {
         lock (lockObj)
         {
             int iValue = bOn ? (ushort)0 : (ushort)1;
             Dmc1000.d1000_out_bit(iBit, iValue);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public bool StopMove(short sAxis)
 {
     if (Enum.IsDefined(typeof(DefaultAxis), sAxis))
     {
         lock (lockObj)
         {
             //减速停止
             Dmc1000.d1000_decel_stop((ushort)sAxis);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public override bool Close()
        {
            try
            {
                StopMove(0);
                StopMove(1);
                StopMove(2);
                StopMove(3);

                Dmc1000.d1000_board_close();
            }
            catch (Exception)
            {
            }

            return(true);
        }
 public void GetAllIOStatus()
 {
     lock (lockObj)
     {
         try
         {
             for (int index = 0; index < 48; index++)
             {
                 //int iTemp = Dmc1000.d1000_in_bit(index);
                 _bArrayInputSta[index]  = Dmc1000.d1000_in_bit(index) == 1 ? false : true;
                 _bArrayOutputSta[index] = Dmc1000.d1000_get_outbit(index) == 1 ? false : true;
             }
         }
         catch
         {
         }
     }
 }
 public bool ReferPosMove(short sAxis, double dAcc, double dDec, double dSpeed, double pos)
 {
     if (Enum.IsDefined(typeof(DefaultAxis), sAxis))
     {
         lock (lockObj)
         {
             if (dSpeed < 0)
             {
                 pos = pos * -1;
             }
             dSpeed = Math.Abs(dSpeed);
             Dmc1000.d1000_start_t_move(sAxis, (int)pos, 0, (int)dSpeed, 0);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
        override public bool Init(HardwareData hardwareData)
        {
            LeadShineMotionCardData tempInfo = (LeadShineMotionCardData)hardwareData;

            if (iCardTotal > 0)
            {
                if (iCardTotal >= tempInfo.Index)
                {
                    bInitOk = true;
                }
                else
                {
                    bInitOk = false;
                }
            }
            else
            {
                iCardTotal = Dmc1000.d1000_board_init();
                if (iCardTotal <= 0)//控制卡初始化
                {
                    bInitOk = false;
                    return(false);
                }
                if (iCardTotal >= tempInfo.Index)
                {
                    bInitOk = true;
                }
                else
                {
                    bInitOk = false;
                }
            }
            iCardIndex = (ushort)tempInfo.Index;
            System.Threading.Thread threadScan = new System.Threading.Thread(ScanThreadFunction);
            threadScan.IsBackground = true;
            threadScan.Start();
            return(true);
        }
        public void GetAllMotionStatus()
        {
            lock (lockObj)
            {
                for (ushort iAxis = 0; iAxis < 4; iAxis++)
                {
                    int iCurrent = 0;
                    try
                    {
                        _dArrayTargetPos[iAxis] = Dmc1000.d1000_get_command_pos(iAxis);
                        _dArrayCurrPos[iAxis]   = Dmc1000.d1000_get_command_pos(iAxis);
                        _bArrayIsMoving[iAxis]  = Dmc1000.d1000_check_done(iAxis) == 0 ? true : false;

                        iCurrent = Dmc1000.d1000_get_axis_status(iAxis);
                    }
                    catch
                    {
                    }
                    if ((iCurrent & 0x4) == 0)
                    {
                        _bArrayHomeSta[iAxis] = false;
                    }
                    else
                    {
                        _bArrayHomeSta[iAxis] = true;
                    }

                    //if ((uiCurrent & 0x1) == 0)
                    //{
                    //    _bArrayAlarmSta[iAxis] = false;
                    //}
                    //else
                    //{
                    //    _bArrayAlarmSta[iAxis] = true;
                    //}
                    //if ((uiCurrent & 0x2) == 0)
                    //{
                    //    _bArrayCWLLimitSta[iAxis] = false;
                    //}
                    //else
                    //{
                    //    _bArrayCWLLimitSta[iAxis] = true;
                    //}
                    //if ((uiCurrent & 0x4) == 0)
                    //{
                    //    _bArrayCCWLLimitSta[iAxis] = false;
                    //}
                    //else
                    //{
                    //    _bArrayCCWLLimitSta[iAxis] = true;
                    //}
                    //if ((uiCurrent & 0x10) == 0)
                    //{
                    //    _bArrayHomeSta[iAxis] = false;
                    //}
                    //else
                    //{
                    //    _bArrayHomeSta[iAxis] = true;
                    //}
                }
            }
        }