using CookComputing.XmlRpc;

namespace MeasureThread
{
    /// <summary>
    /// 客户端服务类-> 公共工具类(XmlRpcClient)
    /// </summary>
    public static class XmlRpcClient
    {
        // 访问路径http://localhost:8080/XmlRpcWebServer
        //public static string urlstring = "http://localhost:8019/MathService.ashx";
        /// <summary>
        /// 获取接口：用于调用方法；
        /// </summary>
        /// <param name="urlstr">访问服务器服务类路径</param>
        /// <returns>instance</returns>
        public static IAutoFocus getInstance(string urlstr)
        {
            // 用XmlRpcProxyGen创建接口: 只有此接口实现IXmlRpcProxy接口才能添加url值；
            IAutoFocus service = XmlRpcProxyGen.Create<IAutoFocus>();
            service.Timeout = 5 * 60 * 1000;
            service.XmlEncoding = new System.Text.UTF8Encoding();
            service.Url = urlstr;

            return service;
        }

      
        /// <summary>
        /// 对焦
        /// </summary>
        /// <returns></returns>
        public static string autofocusstig(int search_step, int iter_n, double wd_searh_factor, double stig_range, double iter_range_damping, string urlstr)//,bool normalized
        {
            string xrs;
            //调取接口方法
            IAutoFocus method = getInstance(urlstr);
            xrs = method.autofocusstig( search_step, iter_n, wd_searh_factor, stig_range, iter_range_damping);//,normalized

            return xrs;
        }
        /// <summary>
        /// 对焦
        /// </summary>
        /// <returns></returns>
        public static string autofocus(int search_step, double wd_searh_factor, double retry, bool refine, string urlstr)//,bool normalized
        {
            string xrs;
            //调取接口方法
            IAutoFocus method = getInstance(urlstr);
            xrs = method.autofocus( search_step,  wd_searh_factor,  retry,  refine);//,normalized

            return xrs;
        }
    }
}
