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 MicManager: IMicController
    {
        private static MicManager uniqueInstance;

        // 定义一个标识确保线程同步
        private static readonly object locker = new object();


        /// <summary>
        /// 定义公有方法提供一个全局访问点,同时你也可以定义公有属性来提供全局访问点
        /// </summary>
        /// <returns></returns>
        public static MicManager GetInstance()
        {
            // 当第一个线程运行到这里时，此时会对locker对象 "加锁"，
            // 当第二个线程运行该方法时，首先检测到locker对象为"加锁"状态，该线程就会挂起等待第一个线程解锁
            // lock语句运行完之后（即线程运行完之后）会对该对象"解锁"
            // 双重锁定只需要一句判断就可以了
            if (uniqueInstance == null)
            {
                lock (locker)
                {
                    // 如果类的实例不存在则创建，否则直接返回
                    if (uniqueInstance == null)
                    {
                        uniqueInstance = new MicManager();
                    }
                }
            }
            return uniqueInstance;
        }
        public double GetMaxMoveSpeed      (IMicroscope Manager                    )
        {
            return AxisController.GetMaxMoveSpeed(Manager);
        }
        public double GetMinMoveSpeed      (IMicroscope Manager                    )
        {
            return AxisController.GetMinMoveSpeed(Manager);
        }
        public string GetSpeedUnit         (IMicroscope Manager,int index          )
        {
            return AxisController.GetSpeedUnit(Manager, index);
        }
        public int GetSpeedUnitCount       (IMicroscope Manager                    )
        {
            return AxisController.GetSpeedUnitCount(Manager);
        }
        public int Move                   (IMicroscope Manager, double moveSpeed  )
        {
            return AxisController.Move(Manager, moveSpeed);
        }
        public int Stop                   (IMicroscope Manager)
        {
            return AxisController.Stop(Manager);
        }
        public double  GetContinualAcceleration            (IMicroscope Manager                                    )
        {
            return AxisController.GetContinualAcceleration(Manager);
        }
        public string  GetContinualAccelerationUnit        (IMicroscope Manager, int index                         )
        {
            return AxisController.GetContinualAccelerationUnit(Manager, index);
        }
        public int     GetContinualAccelerationUnitCount   (IMicroscope Manager                                    )
        {
            return AxisController.GetContinualAccelerationUnitCount(Manager);
        }
        public double  GetContinualSpeed                   (IMicroscope Manager                                    )
        {
            return AxisController.GetContinualSpeed(Manager);
        }
        public string  GetContinualSpeedUnit               (IMicroscope Manager, int index                         )
        {
            return AxisController.GetContinualSpeedUnit(Manager, index);
        }
        public int     GetContinualSpeedUnitCount          (IMicroscope Manager                                    )
        {
            return AxisController.GetContinualSpeedUnitCount(Manager);
        }
        public double  GetContinualStartSpeed              (IMicroscope Manager                                    )
        {
            return AxisController.Stop(Manager);
        }
        public string  GetContinualStartSpeedUnit          (IMicroscope Manager, int index                         )
        {
            return AxisController.GetContinualStartSpeedUnit(Manager, index);
        }
        public int     GetContinualStartSpeedUnitCount     (IMicroscope Manager                                    )
        {
            return AxisController.GetContinualStartSpeedUnitCount(Manager);
        }
        public double  GetMaxContinualAcceleration         (IMicroscope Manager                                    )
        {
            return AxisController.GetMaxContinualAcceleration(Manager);
        }
        public double  GetMaxContinualSpeed                (IMicroscope Manager                                    )
        {
            return AxisController.GetMaxContinualSpeed(Manager);
        }
        public double  GetMaxContinualStartSpeed           (IMicroscope Manager                                    )
        {
            return AxisController.GetMaxContinualStartSpeed(Manager);
        }
        public double  GetMinContinualAcceleration         (IMicroscope Manager                                    )
        {
            return AxisController.GetMinContinualAcceleration(Manager);
        }
        public double  GetMinContinualSpeed                (IMicroscope Manager                                    )
        {
            return AxisController.GetMinContinualSpeed(Manager);
        }
        public double  GetMinContinualStartSpeed           (IMicroscope Manager                                    )
        {
            return AxisController.GetMinContinualStartSpeed(Manager);
        }
        public int     SetContinualAcceleration            (IMicroscope Manager, double continualAcceleration      )
        {
            return AxisController.SetContinualAcceleration(Manager, continualAcceleration);
        }
        public int     SetContinualSpeed                   (IMicroscope Manager, double continualSpeed             )
        {
            return AxisController.SetContinualSpeed(Manager, continualSpeed);
        }
        public int     SetContinualStartSpeed              (IMicroscope Manager, double continualSpeed)
        {
            return AxisController.SetContinualStartSpeed(Manager, continualSpeed);
        }
        public int             IsOnHWLimit                  (IMicroscope Manager                                                               ) { return AxisController.IsOnHWLimit                 ( Manager                                                         ); }
        public double          AlignPosition                (IMicroscope Manager, double position                                              ) { return AxisController.AlignPosition               ( Manager, position                                               ); }
        public double          GetMaxPosition               (IMicroscope Manager                                                               ) { return AxisController.GetMaxPosition              ( Manager                                                         ); }
        public double          GetMinPosition               (IMicroscope Manager                                                               ) { return AxisController.GetMinPosition              ( Manager                                                         ); }
        public double          GetPosition                  (IMicroscope Manager                                                               ) { return AxisController.GetPosition                 ( Manager                                                         ); }
        public string          GetPositionUnit              (IMicroscope Manager, int     index                                                ) { return AxisController.GetPositionUnit             ( Manager,  index                                                 ); }
        public int             GetPositionUnitCount         (IMicroscope Manager                                                               ) { return AxisController.GetPositionUnitCount        ( Manager                                                         ); }
        public double          GetTargetPosition            (IMicroscope Manager                                                               ) { return AxisController.GetTargetPosition           ( Manager                                                         ); }
        public double          MaxDeviation                 (IMicroscope Manager                                                               ) { return AxisController.MaxDeviation                ( Manager                                                         ); }
        public int             SetPosition                  (IMicroscope Manager, double   position    , int mode                              ) { return AxisController.SetPosition                 ( Manager,   position    ,  mode                                  ); }
        public int             SetPosition                  (IMicroscope Manager, double   position    , int mode      , int timeout           ) { return AxisController.SetPosition                 ( Manager,   position    ,  mode      , timeout                   ); }
        public double          StepWidth                    (IMicroscope Manager                                                               ) { return AxisController.StepWidth                   ( Manager                                                         ); }
        public double          TypicalDeviation             (IMicroscope Manager                                                               ) { return AxisController.TypicalDeviation            ( Manager                                                         ); }
        public int             HasOnOff                    (IMicroscope Manager                                                                ) { return AxisController.HasOnOff                    (Manager                                                          ); }
        public int             HasLoadWork                 (IMicroscope Manager                                                                ) { return AxisController.HasLoadWork                 (Manager                                                          ); }
        public int             HasSWLimit                  (IMicroscope Manager                                                                ) { return AxisController.HasSWLimit                  (Manager                                                          ); }
        public int             IsOnSWLimit                 (IMicroscope Manager                                                                ) { return AxisController.IsOnSWLimit                 (Manager                                                          ); }
        public int             CoordinateDirection         (IMicroscope Manager                                                                ) { return AxisController.CoordinateDirection         (Manager                                                          ); }
        public int             ClosedLoop                  (IMicroscope Manager                                                                ) { return AxisController.ClosedLoop                  (Manager                                                          ); }
        public int             HasHandwheelOnOff           (IMicroscope Manager                                                                ) { return AxisController.HasHandwheelOnOff           (Manager                                                          ); }
        public int             Calibrate                   (IMicroscope Manager, int       calMode     , int cmdMode                           ) { return AxisController.Calibrate                   (Manager,    calMode     , cmdMode                                ); }
        public int             Calibrate                   (IMicroscope Manager, int       calMode     , int cmdMode   , int timeout           ) { return AxisController.Calibrate                   (Manager,    calMode     , cmdMode   , timeout                    ); }
        public int             EnableSWLimit               (IMicroscope Manager, bool      upper       , bool enable                           ) { return AxisController.EnableSWLimit               (Manager,    upper       ,  enable                                ); }
        public int             GetHandwheelOnOff           (IMicroscope Manager                                                                ) { return AxisController.GetHandwheelOnOff           (Manager                                                          ); }
        public double          GetMeasurementOrigin        (IMicroscope Manager                                                                ) { return AxisController.GetMeasurementOrigin        (Manager                                                          ); }
        public double          GetMeasurementPosition      (IMicroscope Manager                                                                ) { return AxisController.GetMeasurementPosition      (Manager                                                          ); }
        public int             GetOnOff                    (IMicroscope Manager                                                                ) { return AxisController.GetOnOff                    (Manager                                                          ); }
        public double          GetSWLimit                  (IMicroscope Manager, bool      upper                                               ) { return AxisController.GetSWLimit                  (Manager,    upper                                                ); }
        public int             IsSWLimitEnabled            (IMicroscope Manager, bool      upper                                               ) { return AxisController.IsSWLimitEnabled            (Manager,    upper                                                ); }
        public int             SetHandwheelOnOff           (IMicroscope Manager, bool      onOff                                               ) { return AxisController.SetHandwheelOnOff           (Manager,    onOff                                                ); }
        public int             SetMeasurementOrigin        (IMicroscope Manager, double    origin                                              ) { return AxisController.SetMeasurementOrigin        (Manager,    origin                                               ); }
        public int             SetMeasurementPosition      (IMicroscope Manager, double    position                                            ) { return AxisController.SetMeasurementPosition      (Manager,    position                                             ); }
        public int             SetOnOff                    (IMicroscope Manager, bool      onOff                                               ) { return AxisController.SetOnOff                    (Manager,    onOff                                                ); }
        public int             SetSWLimit                  (IMicroscope Manager, bool      upper       , double limit                          ) { return AxisController.SetSWLimit                  (Manager,    upper       , limit                                  ); }
        public int             ZDriverIsMonitoring                   (IMicroscope Manager                ) { return AxisController.ZDriverIsMonitoring                   (Manager); }
        public int             ZDriverIsLocked                       (IMicroscope Manager                ) { return AxisController.ZDriverIsLocked                       (Manager); }
        public int             ZDriverIsBusy                         (IMicroscope Manager                ) { return AxisController.ZDriverIsBusy                         (Manager); }
        public int             ZDriverHasMonitoring                  (IMicroscope Manager                ) { return AxisController.ZDriverHasMonitoring                  (Manager); }
        public int             ZDriverIsLockedForClient              (IMicroscope Manager                ) { return AxisController.ZDriverIsLockedForClient              (Manager); }
        public int             ZDriverIsMonitoringForClient          (IMicroscope Manager                ) { return AxisController.ZDriverIsMonitoringForClient          (Manager); }
        public int             ZDriverLock                           (IMicroscope Manager                ) { return AxisController.ZDriverLock                           (Manager); }
        public int             ZDriverStartMonitoring                (IMicroscope Manager                ) { return AxisController.ZDriverStartMonitoring                (Manager); }
        public int             ZDriverStopMonitoring                 (IMicroscope Manager                ) { return AxisController.ZDriverStopMonitoring                 (Manager); }
        public int             ZDriverUnlock                         (IMicroscope Manager                ) { return AxisController.ZDriverUnlock                         (Manager); }
        public int             ZDriverWaitReady                      (IMicroscope Manager, int timeout   ) { return AxisController.ZDriverWaitReady                      (Manager, timeout); }
        
        public int             ObjectiveAbsPosition        (IMicroscope Manager                                                                ) { return ObjectiveController.ObjectiveAbsPosition        (Manager                                                     ); }
        public int             ObjectiveMinPosition        (IMicroscope Manager                                                                ) { return ObjectiveController.ObjectiveMinPosition        (Manager                                                     ); }
        public int             ObjectiveMaxPosition        (IMicroscope Manager                                                                ) { return ObjectiveController.ObjectiveMaxPosition        (Manager                                                     ); }
        public int             ObjectiveSetPosition        (IMicroscope Manager, int position, int mode, int timeout                           ) { return ObjectiveController.ObjectiveSetPosition        (Manager, position, mode, timeout                            ); }
        public int             ObjectiveSetPosition        (IMicroscope Manager, int position, int mode                                        ) { return ObjectiveController.ObjectiveSetPosition        (Manager, position, mode                                     ); }
        public int             ObjectiveIsMonitoring                   (IMicroscope Manager                ) { return ObjectiveController.ObjectiveIsMonitoring                   (Manager); }
        public int             ObjectiveIsLocked                       (IMicroscope Manager                ) { return ObjectiveController.ObjectiveIsLocked                       (Manager); }
        public int             ObjectiveIsBusy                         (IMicroscope Manager                ) { return ObjectiveController.ObjectiveIsBusy                         (Manager); }
        public int             ObjectiveHasMonitoring                  (IMicroscope Manager                ) { return ObjectiveController.ObjectiveHasMonitoring                  (Manager); }
        public int             ObjectiveIsLockedForClient              (IMicroscope Manager                ) { return ObjectiveController.ObjectiveIsLockedForClient              (Manager); }
        public int             ObjectiveIsMonitoringForClient          (IMicroscope Manager                ) { return ObjectiveController.ObjectiveIsMonitoringForClient          (Manager); }
        public int             ObjectiveLock                           (IMicroscope Manager                ) { return ObjectiveController.ObjectiveLock                           (Manager); }
        public int             ObjectiveStartMonitoring                (IMicroscope Manager                ) { return ObjectiveController.ObjectiveStartMonitoring                (Manager); }
        public int             ObjectiveStopMonitoring                 (IMicroscope Manager                ) { return ObjectiveController.ObjectiveStopMonitoring                 (Manager); }
        public int             ObjectiveUnlock                         (IMicroscope Manager                ) { return ObjectiveController.ObjectiveUnlock                         (Manager); }
        public int             ObjectiveWaitReady                      (IMicroscope Manager, int timeout   ) { return ObjectiveController.ObjectiveWaitReady                      (Manager, timeout); }

        public int     LampType                (IMicroscope Manager                                                        ) { return LampController.LampType                (Manager                                      ); }
        public int     LampIsActive            (IMicroscope Manager                                                        ) { return LampController.LampIsActive            (Manager                                      ); }
        public int     LampLightPathLocation   (IMicroscope Manager                                                        ) { return LampController.LampLightPathLocation   (Manager                                      ); }
        public int     LampHasRemote           (IMicroscope Manager                                                        ) { return LampController.LampHasRemote           (Manager                                      ); }
        public int     LampHasOnOff            (IMicroscope Manager                                                        ) { return LampController.LampHasOnOff            (Manager                                      ); }
        public int     LampHas3200K            (IMicroscope Manager                                                        ) { return LampController.LampHas3200K            (Manager                                      ); }
        public int     LampGet3200K            (IMicroscope Manager                                                        ) { return LampController.LampGet3200K            (Manager                                      ); }
        public int     LampGetOnOff            (IMicroscope Manager                                                        ) { return LampController.LampGetOnOff            (Manager                                      ); }
        public int     LampGetRemote           (IMicroscope Manager                                                        ) { return LampController.LampGetRemote           (Manager                                      ); }
        public int     LampSetRemote           (IMicroscope Manager , bool     onOff                                       ) { return LampController.LampSetRemote           (Manager ,onOff                               ); }
        public int     LampSet3200K            (IMicroscope Manager , bool     onOff       , int mode                      ) { return LampController.LampSet3200K            (Manager ,onOff       , mode                  ); }
        public int     LampSetOnOff            (IMicroscope Manager , bool     onOff       , int mode                      ) { return LampController.LampSetOnOff            (Manager ,onOff       , mode                  ); }
        public int     LampSet3200K            (IMicroscope Manager , bool     onOff       , int mode      , int timeout   ) { return LampController.LampSet3200K            (Manager ,onOff       , mode      , timeout   ); }
        public int     LampSetOnOff            (IMicroscope Manager , bool     onOff       , int mode      , int timeout   ) { return LampController.LampSetOnOff            (Manager ,onOff       , mode      , timeout   ); }
        public int     LampIsOnHWLimit         (IMicroscope Manager                                                        ) { return LampController.LampIsOnHWLimit         (Manager                                      ); }
        public double  LampGetMaxPosition      (IMicroscope Manager                                                        ) { return LampController.LampGetMaxPosition      (Manager                                      ); }
        public double  LampGetMinPosition      (IMicroscope Manager                                                        ) { return LampController.LampGetMinPosition      (Manager                                      ); }
        public double  LampGetPosition         (IMicroscope Manager                                                        ) { return LampController.LampGetPosition         (Manager                                      ); }
        public int     LampGetPositionUnitCount(IMicroscope Manager                                                        ) { return LampController.LampGetPositionUnitCount(Manager                                      ); }
        public double  LampGetTargetPosition   (IMicroscope Manager                                                        ) { return LampController.LampGetTargetPosition   (Manager                                      ); }
        public double  LampMaxDeviation        (IMicroscope Manager                                                        ) { return LampController.LampMaxDeviation        (Manager                                      ); }
        public double  LampStepWidth           (IMicroscope Manager                                                        ) { return LampController.LampStepWidth           (Manager                                      ); }
        public double  LampTypicalDeviation    (IMicroscope Manager                                                        ) { return LampController.LampTypicalDeviation    (Manager                                      ); }
        public string  LampGetPositionUnit     (IMicroscope Manager , int      index                                       ) { return LampController.LampGetPositionUnit     (Manager ,index                               ); }
        public int     LampSetPosition         (IMicroscope Manager , double   position    , int mode                      ) { return LampController.LampSetPosition         (Manager ,position    , mode                  ); }
        public int     LampSetPosition         (IMicroscope Manager , double   position    , int mode      , int timeout   ) { return LampController.LampSetPosition         (Manager ,position    , mode      , timeout   ); }
        public int     LampIsMonitoring                   (IMicroscope Manager                ) { return LampController.LampIsMonitoring         (Manager); }
        public int     LampIsLocked                       (IMicroscope Manager                ) { return LampController.LampIsLocked             (Manager); }
        public int     LampIsBusy                         (IMicroscope Manager                ) { return LampController.LampIsBusy               (Manager); }
        public int     LampHasMonitoring                  (IMicroscope Manager                ) { return LampController.LampHasMonitoring        (Manager); }
        public int     LampIsLockedForClient              (IMicroscope Manager                ) { return LampController.LampIsLockedForClient    (Manager); }
        public int     LampIsMonitoringForClient          (IMicroscope Manager                ) { return LampController.LampIsMonitoringForClient(Manager); }
        public int     LampLock                           (IMicroscope Manager                ) { return LampController.LampLock                 (Manager); }
        public int     LampStartMonitoring                (IMicroscope Manager                ) { return LampController.LampStartMonitoring      (Manager); }
        public int     LampStopMonitoring                 (IMicroscope Manager                ) { return LampController.LampStopMonitoring       (Manager); }
        public int     LampUnlock                         (IMicroscope Manager                ) { return LampController.LampUnlock               (Manager); }
        public int     LampWaitReady                      (IMicroscope Manager, int timeout   ) { return LampController.LampWaitReady            (Manager, timeout); }
        public int     SetLampILTLSwitch                  (IMicroscope Manager, bool enable, int mode                                 ){ return LampController.SetLampILTLSwitch(Manager, enable, mode); }
        public int     GetLampILTLSwitch                  (IMicroscope Manager                                                        ){ return LampController.GetLampILTLSwitch(Manager); }
        public double  ApblGetMaxMoveSpeed     (IMicroscope Manager                                                                            ) { return ApblController.ApblGetMaxMoveSpeed     (Manager                                                          ); }
        public double  ApblGetMinMoveSpeed     (IMicroscope Manager                                                                            ) { return ApblController.ApblGetMinMoveSpeed     (Manager                                                          ); }
        public int     ApblGetSpeedUnitCount   (IMicroscope Manager                                                                            ) { return ApblController.ApblGetSpeedUnitCount   (Manager                                                          ); }
        public int     ApblStop                (IMicroscope Manager                                                                            ) { return ApblController.ApblStop                (Manager                                                          ); }
        public int     ApblIsOnHWLimit         (IMicroscope Manager                                                                            ) { return ApblController.ApblIsOnHWLimit         (Manager                                                          ); }
        public double  ApblGetMaxPosition      (IMicroscope Manager                                                                            ) { return ApblController.ApblGetMaxPosition      (Manager                                                          ); }
        public double  ApblGetMinPosition      (IMicroscope Manager                                                                            ) { return ApblController.ApblGetMinPosition      (Manager                                                          ); }
        public double  ApblGetPosition         (IMicroscope Manager                                                                            ) { return ApblController.ApblGetPosition         (Manager                                                          ); }
        public int     ApblGetPositionUnitCount(IMicroscope Manager                                                                            ) { return ApblController.ApblGetPositionUnitCount(Manager                                                          ); }
        public double  ApblGetTargetPosition   (IMicroscope Manager                                                                            ) { return ApblController.ApblGetTargetPosition   (Manager                                                          ); }
        public double  ApblMaxDeviation        (IMicroscope Manager                                                                            ) { return ApblController.ApblMaxDeviation        (Manager                                                          ); }
        public double  ApblStepWidth           (IMicroscope Manager                                                                            ) { return ApblController.ApblStepWidth           (Manager                                                          ); }
        public double  ApblTypicalDeviation    (IMicroscope Manager                                                                            ) { return ApblController.ApblTypicalDeviation    (Manager                                                          ); }
        public string  ApblGetSpeedUnit        (IMicroscope Manager                    , int       index                                       ) { return ApblController.ApblGetSpeedUnit        (Manager                    , index                               ); }
        public string  ApblGetPositionUnit     (IMicroscope Manager                    , int       index                                       ) { return ApblController.ApblGetPositionUnit     (Manager                    , index                               ); }
        public int     ApblMove                (IMicroscope Manager                    , double    moveSpeed                                   ) { return ApblController.ApblMove                (Manager                    , moveSpeed                           ); }
        public double  ApblAlignPosition       (IMicroscope Manager                    , double    position                                    ) { return ApblController.ApblAlignPosition       (Manager                    , position                            ); }
        public int     ApblSetPosition         (IMicroscope Manager                    , double    position    , int mode      , int timeout   ) { return ApblController.ApblSetPosition         (Manager                    , position    , mode      , timeout   ); }
        public int     ApblSetPosition         (IMicroscope Manager                    , double    position    , int mode                      ) { return ApblController.ApblSetPosition         (Manager                    , position    , mode                  ); }
        public int     ApblIsMonitoring                   (IMicroscope Manager                ) { return ApblController.ApblIsMonitoring         (Manager); }
        public int     ApblIsLocked                       (IMicroscope Manager                ) { return ApblController.ApblIsLocked             (Manager); }
        public int     ApblIsBusy                         (IMicroscope Manager                ) { return ApblController.ApblIsBusy               (Manager); }
        public int     ApblHasMonitoring                  (IMicroscope Manager                ) { return ApblController.ApblHasMonitoring        (Manager); }
        public int     ApblIsLockedForClient              (IMicroscope Manager                ) { return ApblController.ApblIsLockedForClient    (Manager); }
        public int     ApblIsMonitoringForClient          (IMicroscope Manager                ) { return ApblController.ApblIsMonitoringForClient(Manager); }
        public int     ApblLock                           (IMicroscope Manager                ) { return ApblController.ApblLock                 (Manager); }
        public int     ApblStartMonitoring                (IMicroscope Manager                ) { return ApblController.ApblStartMonitoring      (Manager); }
        public int     ApblStopMonitoring                 (IMicroscope Manager                ) { return ApblController.ApblStopMonitoring       (Manager); }
        public int     ApblUnlock                         (IMicroscope Manager                ) { return ApblController.ApblUnlock               (Manager); }
        public int     ApblWaitReady                      (IMicroscope Manager, int timeout   ) { return ApblController.ApblWaitReady            (Manager, timeout); }
    }   

}
