Browse Source

更新测量线程的Web调用。更改了韩工程序的测量线程初始化程序。更改了Web调用接口可配置程序。

@wang_qi0307 5 years ago
parent
commit
067a7fdedf

+ 2 - 0
HOZProject/App.config

@@ -51,5 +51,7 @@
       <add key="WebServerIP" value="127.0.0.1"/>
       <!--远程IP端口-->
       <add key="WebServerPort" value="12345"/>
+      <!--远程算法地址-->
+      <add key="WebServerUrl" value="FIB_degree_recognize,test2,FIB_verify,test4,test5,test6,test7,test8"/>
     </appSettings>
 </configuration>

+ 5 - 1
HOZProject/FormHOZMain.cs

@@ -44,6 +44,8 @@ namespace HOZProject
         UControl_Init uControl_Init = null;
         //流程控制
         public int m_MeasureType = (int)MeasureMsgManage.measureType.Cut;
+
+        Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
         #endregion
 
         #region 构造函数
@@ -66,7 +68,9 @@ namespace HOZProject
         #region 测量线程
         void DoWork(object sender, DoWorkEventArgs e)
         {
-            m_Ms = new Measure();
+            m_Ms = new Measure(ConfigurationManager.AppSettings["WebServerIP"].ToString(),
+                ConfigurationManager.AppSettings["WebServerPort"].ToString(),
+                ConfigurationManager.AppSettings["WebServerUrl"].ToString());
             m_Ms.InitMeas(m_MeasureFile);
             m_Ms.SendThreadStatus += new ThreadStatusHandler(displayMessage); //注册事件
             m_Ms.SendCutHolesStatus += new CutHolesStatusHandler(displayCutHoleMessage); //注册事件

+ 1 - 1
HOZProject/FormUnitControl.cs

@@ -38,7 +38,7 @@ namespace HOZProject
         private String path = Directory.GetCurrentDirectory();
         private int st_flag = 0;
 
-        WebResult wr = new WebResult("127.0.0.1", "18080");
+        WebResult wr = new WebResult("127.0.0.1", "18080","");
 
         String[] sT;
         String[] firms;

+ 2 - 2
HOZProject/UserControls/UControl_Init.cs

@@ -164,7 +164,7 @@ namespace HOZProject
             cfm.Location_Voltage = Convert.ToSingle(cbbWQGD.Text);
             cfm.Photograph_Magnification = Convert.ToSingle(cbbWPZF.Text);
             cfm.Photograph_Voltage = Convert.ToSingle(cbbWPZD.Text);
-            cfm.FocusMode = chkManul.Checked;
+            //cfm.FocusMode = chkManul.Checked;
             if (cbbWXZ.SelectedIndex == 0)
             {
                 cfm.Correction_Angle = 36;
@@ -295,7 +295,7 @@ namespace HOZProject
 
                 MeasureParam cfm = new MeasureParam();
                 cfm.Is_Photograph = chkWIsP.Checked;
-                cfm.FocusMode = chkManul.Checked;
+                cfm.FocusMode = Convert.ToInt32(config.AppSettings.Settings["Focus_Mode"].Value);
                 cfm.PT = chkWPT.Checked;
                 //自动对焦模式
                 //cfm.FocusMode = chkManul.Checked;

+ 4 - 7
MeasureThread/Measure.cs

@@ -402,7 +402,7 @@ namespace MeasureThread
             }
         }
 
-        public WebResult wr = new WebResult("127.0.0.1", "18080");
+        public WebResult wr = null;
 
         public event ThreadStatusHandler SendThreadStatus;  // 声明事件
         public event CutHolesStatusHandler SendCutHolesStatus;  // 声明事件
@@ -479,16 +479,13 @@ namespace MeasureThread
         }
 
         //构造函数
-        public Measure(String webServerIP, String webServerPort)
-        {
-            Init();
-        }
-
-        private void Init()
+        public Measure(String webServerIP, String webServerPort, String webServerUrl)
         {
             MeasParam = new MeasureParam();
             TStatus = new ThreadStatus();
             cutHoles = new List<MeasureData.CutHole>();
+            //配置远程连接
+            wr = new WebResult(webServerIP,webServerPort,webServerUrl);
         }
 
         //初始化测量业务, 读测量文件,判断是否有可测试的切孔

+ 67 - 9
WebManager/WebResult.cs

@@ -20,6 +20,7 @@ namespace WebManager
         private String Url = "";
         private const String Post = "Post";
         private const String Content_Type= "Content-Type:application/json";
+        private String[] _url = new string[8];
 
         #endregion
 
@@ -28,10 +29,11 @@ namespace WebManager
         /// </summary>
         /// <param name="ws_ip">WebServer的IP地址</param>
         /// <param name="ws_port">WebServer的端口号</param>
-        public WebResult(String ws_ip,String ws_port)
+        public WebResult(String ws_ip,String ws_port,String ws_url)
         {
             this.webServer_IP = ws_ip;
             this.webServer_Port = ws_port;
+            this._url = ws_url.Split(',');
             //更新Web网址
             Update_Url();
         }
@@ -96,7 +98,14 @@ namespace WebManager
         /// <returns>json字符串</returns>
         public void Img_OffsetAngle_Direction(String imagePath, int imageType, String firm, out double degree, out int direction, out int state)
         {
-            this.webServer_Path = "FIB_degree_recognize";
+            try
+            {
+                this.webServer_Path = this._url[0];
+            }
+            catch
+            {
+                this.webServer_Path = "FIB_degree_recognize";
+            }
             Update_Url();
             JObject json = new JObject();
             json.Add("img_path", imagePath);
@@ -129,7 +138,14 @@ namespace WebManager
         /// <returns>json字符串</returns>
         public void Img_Cut_Position(String imagePath, int imageType, String firm, out double offsetx, out double offsety, out int state)
         {
-            this.webServer_Path = "test2";
+            try
+            {
+                this.webServer_Path = this._url[1];
+            }
+            catch
+            {
+                this.webServer_Path = "test2";
+            }
             Update_Url();
             JObject json = new JObject();
             json.Add("img_path", imagePath);
@@ -161,7 +177,14 @@ namespace WebManager
         /// <returns>json字符串</returns>
         public void Img_Cut_Success(String imageBefore, String imageAfter, out int state)
         {
-            this.webServer_Path = "FIB_verify";
+            try
+            {
+                this.webServer_Path = this._url[2];
+            }
+            catch
+            {
+                this.webServer_Path = "FIB_verify";
+            }
             Update_Url();
             JObject json = new JObject();
             json.Add("img_before_path", imageBefore);
@@ -185,7 +208,14 @@ namespace WebManager
         /// <returns>json字符串</returns>
         public void Img_Trapezoid_Top_Center_Position(String imagePath, out double offsetx, out double offsety, out int state)
         {
-            this.webServer_Path = "test4";
+            try
+            {
+                this.webServer_Path = this._url[3];
+            }
+            catch
+            {
+                this.webServer_Path = "test4";
+            }
             Update_Url();
             JObject json = new JObject();
             json.Add("img_path", imagePath);
@@ -214,7 +244,14 @@ namespace WebManager
         /// <returns>json字符串</returns>
         public String Img_Auto_Focus(List<String> imagePath)
         {
-            this.webServer_Path = "test5";
+            try
+            {
+                this.webServer_Path = this._url[4];
+            }
+            catch
+            {
+                this.webServer_Path = "test5";
+            }
             Update_Url();
             JObject json = new JObject();
             for(int i=0;i<imagePath.Count;i++)
@@ -240,7 +277,14 @@ namespace WebManager
         /// <returns>json字符串</returns>
         public String Img_Auto_Stigmatic(List<String> imagePath)
         {
-            this.webServer_Path = "test6";
+            try
+            {
+                this.webServer_Path = this._url[5];
+            }
+            catch
+            {
+                this.webServer_Path = "test6";
+            }
             Update_Url();
             JObject json = new JObject();
             for (int i = 0; i < imagePath.Count; i++)
@@ -266,7 +310,14 @@ namespace WebManager
         /// <returns>json字符串</returns>
         public void Img_Center_Position_OffsetAngle_Direction(String imagePath, int imageType, String firm, out double offsetx, out double offsety, out double degree, out int direction, out int state)
         {
-            this.webServer_Path = "test7";
+            try
+            {
+                this.webServer_Path = this._url[6];
+            }
+            catch
+            {
+                this.webServer_Path = "test7";
+            }
             Update_Url();
             JObject json = new JObject();
             json.Add("img_path", imagePath);
@@ -304,7 +355,14 @@ namespace WebManager
         /// <returns>json字符串</returns>
         public void Img_Measure_Size(String imagePath, String ratio, String size, out int state)
         {
-            this.webServer_Path = "test8";
+            try
+            {
+                this.webServer_Path = this._url[7];
+            }
+            catch
+            {
+                this.webServer_Path = "test8";
+            }
             Update_Url();
             JObject json = new JObject();
             json.Add("img_path", imagePath);