Ejemplo n.º 1
0
        protected override bool CustomHomeProcess(Interfaces.IAxis Axis)
        {
            bool        ret   = false;
            LuminosAxis _axis = Axis as LuminosAxis;

            // lock the axis
            if (_axis.Lock())
            {
                try
                {
                    _axis.IsHomed = false;
                    DeviceMessage zaber_ret = _axis.ZaberConversation.Request(Command.Home);

                    if (zaber_ret.HasFault == false)
                    {
                        _axis.IsHomed = true;

                        ret = true;
                    }
                    else
                    {
                        _axis.LastError = string.Format("sdk reported error code {0}", zaber_ret.FlagText);

                        ret = false;
                    }
                }
                catch (Exception ex)
                {
                    _axis.LastError = string.Format("{0}", ex.Message);
                    ret             = false;
                }
                finally
                {
                    // release the axis
                    _axis.Unlock();
                }
            }
            else
            {
                _axis.LastError = "axis is busy";
                ret             = false;
            }

            return(ret);
        }
Ejemplo n.º 2
0
        protected override bool CustomMoveProcess(Interfaces.IAxis Axis, MoveMode Mode, int Speed, int Distance)
        {
            LuminosAxis axis = Axis as LuminosAxis;

            bool ret        = false;
            int  target_pos = 0;

            if (axis.IsHomed == false)
            {
                axis.LastError = "the axis is not homed";
                return(false);
            }

            // lock the axis
            if (axis.Lock())
            {
                // Set the move speed
                if (Mode == MoveMode.ABS)
                {
                    target_pos = Math.Abs(Distance);
                }
                else
                {
                    target_pos = axis.AbsPosition + Distance;
                }

                // Move the the target position
                if (axis.CheckSoftLimitation(target_pos))
                {
                    try
                    {
                        DeviceMessage zaber_msg = axis.ZaberConversation.Request(Command.MoveAbsolute, target_pos);

                        if (zaber_msg.HasFault == false)
                        {
                            ret = true;
                        }
                        else
                        {
                            axis.LastError = string.Format("sdk reported error code {0}", zaber_msg.Text);

                            ret = false;
                        }
                    }
                    catch (RequestReplacedException ex)
                    {
                        DeviceMessage actualResp = ex.ReplacementResponse;
                        if (actualResp.Command == Command.Stop)
                        {
                            // if STOP was send while moving
                            axis.AbsPosition = (int)actualResp.Data;
                            ret = true;
                        }
                        else
                        {
                            axis.LastError = ex.Message;
                            ret            = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        axis.LastError = ex.Message;
                        ret            = false;
                    }
                }
                else
                {
                    axis.LastError = "target position exceeds the limitation.";

                    ret = false;
                }

                axis.Unlock();
            }

            return(ret);
        }