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 ApblController
    {
        public static double      ApblGetMaxMoveSpeed     (IMicroscope Manager                                                                            )
        {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.ApblHandler.GetMaxMoveSpeed(Manager.MTBUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double      ApblGetMinMoveSpeed     (IMicroscope Manager                                                                            )
        {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.ApblHandler.GetMinMoveSpeed(Manager.MTBUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int         ApblGetSpeedUnitCount   (IMicroscope Manager                                                                            )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ApblHandler.GetSpeedUnitCount();
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int         ApblStop                (IMicroscope Manager                                                                            )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ApblHandler.Stop() ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int         ApblIsOnHWLimit         (IMicroscope Manager                                                                            )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {

                result = (int)Manager.ApblHandler.IsOnHWLimit;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double      ApblGetMaxPosition      (IMicroscope Manager                                                                            )
        {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.ApblHandler.GetMaxPosition(Manager.MTBUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double      ApblGetMinPosition      (IMicroscope Manager                                                                            )
        {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.ApblHandler.GetMinPosition(Manager.MTBUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double      ApblGetPosition         (IMicroscope Manager                                                                            )
        {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.ApblHandler.GetPosition(Manager.MTBUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int         ApblGetPositionUnitCount(IMicroscope Manager                                                                            )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ApblHandler.GetPositionUnitCount();
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double      ApblGetTargetPosition   (IMicroscope Manager                                                                            )
        {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.ApblHandler.GetTargetPosition(Manager.MTBUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double      ApblMaxDeviation        (IMicroscope Manager                                                                            )
        {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.ApblHandler.MaxDeviation(Manager.MTBUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double      ApblStepWidth           (IMicroscope Manager                                                                            )
        {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.ApblHandler.StepWidth(Manager.MTBUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double      ApblTypicalDeviation    (IMicroscope Manager                                                                            )
        {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.ApblHandler.TypicalDeviation(Manager.MTBUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static string      ApblGetSpeedUnit        (IMicroscope Manager                    , int       index                                       )
        {
            var result = Settings.DEFAULT_STRING;
            try
            {
                result = Manager.ApblHandler.GetSpeedUnit(index);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static string      ApblGetPositionUnit     (IMicroscope Manager                    , int       index                                       )
        {
            var result = Settings.DEFAULT_STRING;
            try
            {
                result = Manager.ApblHandler.GetPositionUnit(index);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int         ApblMove                (IMicroscope Manager                    , double    moveSpeed                                   )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ApblHandler.Move(moveSpeed, Manager.MTBUnit) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static double      ApblAlignPosition       (IMicroscope Manager                    , double    position                                    )
        {
            var result = Settings.DEFAULT_DOUBLE;
            try
            {
                result = Manager.ApblHandler.AlignPosition(position, Manager.MTBUnit);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int         ApblSetPosition         (IMicroscope Manager                    , double    position    , int mode      , int timeout   )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                Manager.ApblHandler.SetPosition(position, Manager.MTBUnit, (MTBCmdSetModes)mode, timeout);
                result = Settings.RECODE_SUCCEED;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int         ApblSetPosition         (IMicroscope Manager                    , double    position    , int mode)
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                Manager.ApblHandler.SetPosition(position, Manager.MTBUnit, (MTBCmdSetModes)mode);
                result = Settings.RECODE_SUCCEED;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     ApblIsMonitoring            (IMicroscope Manager                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ApblHandler.IsMonitoring ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     ApblIsLocked                (IMicroscope Manager                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ApblHandler.IsLocked ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     ApblIsBusy                  (IMicroscope Manager                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ApblHandler.IsBusy ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     ApblHasMonitoring           (IMicroscope Manager                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ApblHandler.HasMonitoring ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     ApblIsLockedForClient       (IMicroscope Manager                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ApblHandler.IsLockedForClient(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     ApblIsMonitoringForClient   (IMicroscope Manager                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ApblHandler.IsMonitoringForClient(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     ApblLock                    (IMicroscope Manager                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ApblHandler.Lock(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     ApblStartMonitoring         (IMicroscope Manager                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ApblHandler.StartMonitoring(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     ApblStopMonitoring          (IMicroscope Manager                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ApblHandler.StopMonitoring(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     ApblUnlock                  (IMicroscope Manager                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ApblHandler.Unlock(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int     ApblWaitReady               (IMicroscope Manager, int timeout                                           ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ApblHandler.WaitReady(timeout) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
    }
}
