using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZEISS.MTB.Api;
using YQLInterfaces;
using YQLUtils;
namespace ZeissMicroscopeAPI
{
    public class AxisController
    {
        public static double  GetMaxMoveSpeed   (IMicroscope Manager                    )
        {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.MoveHandler.GetMaxMoveSpeed(Manager.MTBSpeedUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;

        }
        public static double  GetMinMoveSpeed   (IMicroscope Manager                    )
        {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.MoveHandler.GetMinMoveSpeed(Manager.MTBSpeedUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static string  GetSpeedUnit      (IMicroscope Manager, int index         )
        {
            var result = Settings.DEFAULT_STRING;
            try
            {
                result = Manager.MoveHandler.GetSpeedUnit(index);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     GetSpeedUnitCount (IMicroscope Manager                    )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.MoveHandler.GetSpeedUnitCount();
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int    Move              (IMicroscope Manager, double moveSpeed  )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.MoveHandler.Move(Manager.MicroscopeID, moveSpeed, Manager.MTBSpeedUnit) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int Stop              (IMicroscope Manager                    )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.MoveHandler.Stop(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  AlignPosition       (IMicroscope Manager                   , double position                           ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.AlignPosition(position, Manager.MTBAxisUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  GetMaxPosition      (IMicroscope Manager                                                               ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetMaxPosition(Manager.MTBAxisUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  GetMinPosition      (IMicroscope Manager                                                               ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetMinPosition(Manager.MTBAxisUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  GetPosition         (IMicroscope Manager                                                               ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetPosition(Manager.MTBAxisUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static string  GetPositionUnit     (IMicroscope Manager                   , int index                                 ) {
            var result = Settings.DEFAULT_STRING;
            try
            {
                result = Manager.AxisHandler.GetPositionUnit(index);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     GetPositionUnitCount(IMicroscope Manager                                                               ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.GetPositionUnitCount();
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  GetTargetPosition   (IMicroscope Manager                                                               ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetTargetPosition(Manager.MTBAxisUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  MaxDeviation        (IMicroscope Manager                                                               ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.MaxDeviation(Manager.MTBAxisUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     SetPosition         (IMicroscope Manager                   , double position, int mode, int timeout    ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                Manager.MoveHandler.SetPosition(Manager.MicroscopeID, position, Manager.MTBAxisUnit, (MTBCmdSetModes)mode, timeout);
                result = Settings.RECODE_SUCCEED;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     SetPosition         (IMicroscope Manager                   , double position, int mode                 ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                Manager.MoveHandler.SetPosition(Manager.MicroscopeID, position, Manager.MTBAxisUnit, (MTBCmdSetModes)mode);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  StepWidth           (IMicroscope Manager                                                               ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.StepWidth(Manager.MTBAxisUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  TypicalDeviation    (IMicroscope Manager) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.TypicalDeviation(Manager.MTBAxisUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     HasContinualAcceleration         (IMicroscope Manager                                                         ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.HasContinualAcceleration ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     HasContinualStartSpeed           (IMicroscope Manager                                                         ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.HasContinualStartSpeed ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  GetContinualAcceleration         (IMicroscope Manager                                                         ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetContinualAcceleration(Manager.MTBSpeedUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static string  GetContinualAccelerationUnit     (IMicroscope Manager, int index                                              ) {
            var result = Settings.DEFAULT_STRING;
            try
            {
                result = Manager.AxisHandler.GetContinualAccelerationUnit(index);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     GetContinualAccelerationUnitCount(IMicroscope Manager                                                         ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.GetContinualStartSpeedUnitCount();
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  GetContinualSpeed                (IMicroscope Manager                                                         ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetContinualSpeed(Manager.MTBSpeedUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static string  GetContinualSpeedUnit            (IMicroscope Manager, int index                                              ) {
            var result = Settings.DEFAULT_STRING;
            try
            {
                result = Manager.AxisHandler.GetContinualAccelerationUnit(index);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     GetContinualSpeedUnitCount       (IMicroscope Manager                                                         ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.GetContinualStartSpeedUnitCount();
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  GetContinualStartSpeed           (IMicroscope Manager                                                         ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetContinualStartSpeed(Manager.MTBSpeedUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static string  GetContinualStartSpeedUnit       (IMicroscope Manager, int index                                              ) {
            var result = Settings.DEFAULT_STRING;
            try
            {
                result = Manager.AxisHandler.GetContinualAccelerationUnit(index);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     GetContinualStartSpeedUnitCount  (IMicroscope Manager                                                         ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.GetContinualStartSpeedUnitCount();
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  GetMaxContinualAcceleration      (IMicroscope Manager                                                         ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetMaxContinualAcceleration(Manager.MTBUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  GetMaxContinualSpeed             (IMicroscope Manager                                                         ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetMaxContinualSpeed(Manager.MTBUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  GetMaxContinualStartSpeed        (IMicroscope Manager                                                         ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetMaxContinualStartSpeed(Manager.MTBSpeedUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  GetMinContinualAcceleration      (IMicroscope Manager                                                         ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetMinContinualAcceleration(Manager.MTBUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  GetMinContinualSpeed             (IMicroscope Manager                                                         ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetMinContinualSpeed(Manager.MTBSpeedUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double  GetMinContinualStartSpeed        (IMicroscope Manager                                                         ) {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetMinContinualStartSpeed(Manager.MTBSpeedUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     SetContinualAcceleration         (IMicroscope Manager,double continualAcceleration                            ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                Manager.AxisHandler.SetContinualAcceleration(continualAcceleration, Manager.MTBUnit);
                result = Settings.RECODE_SUCCEED;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     SetContinualSpeed                (IMicroscope Manager,double continualSpeed                                   ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                Manager.AxisHandler.SetContinualSpeed(continualSpeed, Manager.MTBSpeedUnit);
                result = Settings.RECODE_SUCCEED;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     SetContinualStartSpeed           (IMicroscope Manager,double continualSpeed                                   ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                Manager.AxisHandler.SetContinualStartSpeed(continualSpeed, Manager.MTBSpeedUnit);
                result = Settings.RECODE_SUCCEED;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             IsOnHWLimit                  (IMicroscope Manager                                               )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                var Limit = Manager.AxisHandler.IsOnHWLimit;
                switch (Limit)
                {
                    case MTBLimits.None:
                        result = Settings.RECODE_FAILURE;
                        break;
                    case MTBLimits.Lower:
                        result = Settings.RECODE_SUCCEED;
                        break;
                    case MTBLimits.Upper:
                        result = Settings.RECODE_WARNING;
                        break;
                    default:
                        result = Settings.RECODE_FAILURE;
                        break;
                }
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             HasOnOff                    (IMicroscope Manager                                                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.HasOnOff ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             HasLoadWork                 (IMicroscope Manager                                                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.HasLoadWork ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             HasSWLimit                  (IMicroscope Manager                                                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                var Limit = Manager.AxisHandler.HasSWLimit;
                switch (Limit)
                {
                    case MTBLimits.None:
                        result = Settings.RECODE_FAILURE;
                        break;
                    case MTBLimits.Lower:
                        result = Settings.RECODE_SUCCEED;
                        break;
                    case MTBLimits.Upper:
                        result = Settings.RECODE_WARNING;
                        break;
                    default:
                        result = Settings.RECODE_FAILURE;
                        break;
                }
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             IsOnSWLimit                 (IMicroscope Manager                                                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                var Limit = Manager.AxisHandler.IsOnSWLimit;
                switch (Limit)
                {
                    case MTBLimits.None:
                        result = Settings.RECODE_FAILURE;
                        break;
                    case MTBLimits.Lower:
                        result = Settings.RECODE_SUCCEED;
                        break;
                    case MTBLimits.Upper:
                        result = Settings.RECODE_WARNING;
                        break;
                    default:
                        result = Settings.RECODE_FAILURE;
                        break;
                }
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             CoordinateDirection         (IMicroscope Manager                                                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                var Limit = Manager.AxisHandler.CoordinateDirection;
                switch (Limit)
                {
                    case MTBDirection.Positive:
                        result = Settings.RECODE_FAILURE;
                        break;
                    case MTBDirection.Negative:
                        result = Settings.RECODE_SUCCEED;
                        break;
                    default:
                        result = Settings.RECODE_FAILURE;
                        break;
                }
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             ClosedLoop                  (IMicroscope Manager                                                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                var Limit = Manager.AxisHandler.ClosedLoop;
                switch (Limit)
                {
                    case MTBOnOff.Off:
                        result = Settings.RECODE_FAILURE;
                        break;
                    case MTBOnOff.On:
                        result = Settings.RECODE_SUCCEED;
                        break;
                    default:
                        result = Settings.RECODE_FAILURE;
                        break;
                }
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             HasHandwheelOnOff           (IMicroscope Manager                                                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.HasHandwheelOnOff ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             Calibrate                   (IMicroscope Manager, int calMode, int cmdMode                      )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.Calibrate((MTBCalibrationModes)calMode, (MTBCmdSetModes)cmdMode) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             Calibrate                   (IMicroscope Manager, int calMode, int cmdMode, int timeout         )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.Calibrate((MTBCalibrationModes)calMode, (MTBCmdSetModes)cmdMode, timeout) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             EnableSWLimit               (IMicroscope Manager, bool upper, bool enable                       )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.EnableSWLimit(upper, enable) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             GetHandwheelOnOff           (IMicroscope Manager                                                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.GetHandwheelOnOff() == MTBOnOff.On ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  double          GetMeasurementOrigin        (IMicroscope Manager)
        {

            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetMeasurementOrigin(Manager.MTBAxisUnit);
                
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  double          GetMeasurementPosition      (IMicroscope Manager)
        {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetMeasurementPosition(Manager.MTBAxisUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             GetOnOff                    (IMicroscope Manager                                                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.GetOnOff() == MTBOnOff.On ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  double          GetSWLimit                  (IMicroscope Manager, bool upper                                    )
        {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.AxisHandler.GetSWLimit(upper, Manager.MTBAxisUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
                
        }
         public static  int             IsSWLimitEnabled            (IMicroscope Manager, bool upper                                    )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.IsSWLimitEnabled(upper) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             SetHandwheelOnOff           (IMicroscope Manager, bool onOff                                    )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                Manager.AxisHandler.SetHandwheelOnOff(onOff ? MTBOnOff.On : MTBOnOff.Off);
                result = Settings.RECODE_SUCCEED;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             SetMeasurementOrigin        (IMicroscope Manager, double origin                                 )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                Manager.AxisHandler.SetMeasurementOrigin(origin, Manager.MTBAxisUnit);
                result = Settings.RECODE_SUCCEED;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             SetMeasurementPosition      (IMicroscope Manager, double position                               )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                Manager.AxisHandler.SetMeasurementOrigin(position, Manager.MTBAxisUnit);
                result = Settings.RECODE_SUCCEED;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             SetOnOff                    (IMicroscope Manager, bool onOff                                    )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                Manager.AxisHandler.SetOnOff(onOff ? MTBOnOff.On : MTBOnOff.Off);
                result = Settings.RECODE_SUCCEED;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
         public static  int             SetSWLimit                  (IMicroscope Manager, bool upper, double limit                      )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                Manager.AxisHandler.SetSWLimit(upper, limit, Manager.MTBAxisUnit);
                result = Settings.RECODE_SUCCEED;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static  int             ZDriverIsMonitoring                   (IMicroscope Manager                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.IsMonitoring ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static  int             ZDriverIsLocked                       (IMicroscope Manager                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.IsLocked ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static  int             ZDriverIsBusy                         (IMicroscope Manager                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.IsBusy ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static  int             ZDriverHasMonitoring                  (IMicroscope Manager                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.HasMonitoring ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static  int             ZDriverIsLockedForClient              (IMicroscope Manager                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.IsLockedForClient(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static  int             ZDriverIsMonitoringForClient          (IMicroscope Manager                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.IsMonitoringForClient(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static  int             ZDriverLock                           (IMicroscope Manager                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.Lock(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static  int             ZDriverStartMonitoring                (IMicroscope Manager                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.StartMonitoring(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static  int             ZDriverStopMonitoring                 (IMicroscope Manager                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.StopMonitoring(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static  int             ZDriverUnlock                         (IMicroscope Manager                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.Unlock(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static  int             ZDriverWaitReady                      (IMicroscope Manager, int timeout)
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.AxisHandler.WaitReady(timeout) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
    }
}
