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 ObjectiveController
    {
        public static int  ObjectiveIsMonitoring          (IMicroscope Manager                                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ObjectiveHandler.IsMonitoring ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int ObjectiveIsLocked              (IMicroscope Manager                                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ObjectiveHandler.IsLocked ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int ObjectiveIsBusy                (IMicroscope Manager                                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ObjectiveHandler.IsBusy ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int ObjectiveHasMonitoring         (IMicroscope Manager                                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ObjectiveHandler.HasMonitoring ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int ObjectiveIsLockedForClient     (IMicroscope Manager                                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ObjectiveHandler.IsLockedForClient(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int ObjectiveIsMonitoringForClient (IMicroscope Manager                                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ObjectiveHandler.IsMonitoringForClient(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int ObjectiveLock                  (IMicroscope Manager                                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ObjectiveHandler.Lock(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int ObjectiveStartMonitoring       (IMicroscope Manager                                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ObjectiveHandler.StartMonitoring(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int ObjectiveStopMonitoring        (IMicroscope Manager                                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ObjectiveHandler.StopMonitoring(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int ObjectiveUnlock                (IMicroscope Manager                                                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ObjectiveHandler.Unlock(Manager.MicroscopeID) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int ObjectiveWaitReady             (IMicroscope Manager, int timeout                                                           ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Manager.ObjectiveHandler.WaitReady(timeout) ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int             ObjectiveAbsPosition                    (IMicroscope Manager                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Convert.ToInt32(Manager.ObjectiveHandler.Position);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int             ObjectiveMinPosition                    (IMicroscope Manager                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Convert.ToInt32(Manager.ObjectiveHandler.MinPosition);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int             ObjectiveMaxPosition                    (IMicroscope Manager                                        ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                result = Convert.ToInt32(Manager.ObjectiveHandler.MaxPosition);
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int             ObjectiveSetPosition                    (IMicroscope Manager, int position, int mode, int timeout   ) {
            var result = Settings.RECODE_FAILURE;
            try
            {
                Manager.ObjectiveHandler.SetPosition(Convert.ToInt16(position), (MTBCmdSetModes)mode, timeout);
                result = Settings.RECODE_SUCCEED;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
        public static int             ObjectiveSetPosition                    (IMicroscope Manager, int position, int mode                )
        {
            var result = Settings.RECODE_FAILURE;
            try
            {
                Manager.ObjectiveHandler.SetPosition(Convert.ToInt16(position), (MTBCmdSetModes)mode);
                result = Settings.RECODE_SUCCEED;
            }
            catch (Exception E) { YQLUtil.Print_Exception(E); }
            return result;
        }
    }
}
