Explorar o código

Update WebManager

@wang_qi0307 %!s(int64=5) %!d(string=hai) anos
pai
achega
24c155e0e2

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 599 - 549
HOZProject/FormUnitControl.Designer.cs


+ 83 - 0
HOZProject/FormUnitControl.cs

@@ -19,6 +19,7 @@ using SmartSEMControl;
 using FileManager;
 using System.Xml;
 using MeasureData;
+using WebManager;
 
 
 namespace HOZProject
@@ -35,6 +36,8 @@ namespace HOZProject
         
         private String path = Directory.GetCurrentDirectory();
         private int st_flag = 0;
+
+        WebResult wr = new WebResult("127.0.0.1", "18080", "Huawei/WebServerTest");
         #endregion
 
         #region 构造函数
@@ -1281,5 +1284,85 @@ namespace HOZProject
             FormMeasureTest Measure = new FormMeasureTest();
             Measure.Show();
         }
+
+        private void btnPost1_Click(object sender, EventArgs e)
+        {
+            double degree = 0;
+            int direction = 0;
+            int state = 0;
+            wr.Img_OffsetAngle_Direction("D:/aaaa.jpg", out degree, out direction, out state);
+            lbldegree1.Text = degree.ToString("0.0");
+            lbldirection1.Text = direction.ToString();
+            lblstate1.Text = state.ToString();
+        }
+
+        private void btnPost2_Click(object sender, EventArgs e)
+        {
+            double offsetx = 0;
+            double offsety = 0;
+            int state = 0;
+            wr.Img_Cut_Position("D:/aaaa.jpg", out offsetx, out offsety, out state);
+            lbllocationx.Text = offsetx.ToString("0.0");
+            lbllocationy.Text = offsety.ToString("0.0");
+            lblstate2.Text = state.ToString();
+        }
+
+        private void btnPost3_Click(object sender, EventArgs e)
+        {
+            int state = 0;
+            wr.Img_Cut_Success("D:/aaaa.jpg", "D:/bbbb.jpg", out state);
+            lblstate3.Text = state.ToString();
+        }
+
+        private void btnPost4_Click(object sender, EventArgs e)
+        {
+            double offsetx = 0;
+            double offsety = 0;
+            int state = 0;
+            wr.Img_Trapezoid_Top_Center_Position("D:/aaaa.jpg", out offsetx, out offsety, out state);
+            lbltopcx.Text = offsetx.ToString("0.0");
+            lbltopcy.Text = offsety.ToString("0.0");
+            lblstate4.Text = state.ToString();
+        }
+
+        private void btnPost5_Click(object sender, EventArgs e)
+        {
+            List<string> filenames = new List<string>();
+            filenames.Add("1111111");
+            filenames.Add("2222222");
+            filenames.Add("3333333");
+            lblfocuspath.Text = wr.Img_Auto_Focus(filenames);
+        }
+
+        private void btnPost6_Click(object sender, EventArgs e)
+        {
+            List<string> filenames = new List<string>();
+            filenames.Add("1111111");
+            filenames.Add("2222222");
+            filenames.Add("3333333");
+            lblstigpath.Text = wr.Img_Auto_Focus(filenames);
+        }
+
+        private void btnPost7_Click(object sender, EventArgs e)
+        {
+            double offsetx = 0;
+            double offsety = 0;
+            double degree = 0;
+            int direction = 0;
+            int state = 0;
+            wr.Img_Center_Position_OffsetAngle_Direction("D:/aaaa.jpg", out offsetx, out offsety, out degree, out direction, out state);
+            lblcenterx.Text = offsetx.ToString("0.0");
+            lblcentery.Text = offsety.ToString("0.0");
+            lbldegree2.Text = degree.ToString();
+            lbldirection2.Text = direction.ToString();
+            lblstate5.Text = state.ToString();
+        }
+
+        private void btnPost8_Click(object sender, EventArgs e)
+        {
+            int state = 0;
+            wr.Img_Measure_Size("D:/aaaa.jpg", "1000", "0.005", out state);
+            lblstate6.Text = state.ToString();
+        }
     }
 }

+ 4 - 0
HOZProject/UnitControl.csproj

@@ -125,6 +125,10 @@
       <Project>{bf7f80b0-a6da-4470-a331-4c96057fc7fa}</Project>
       <Name>SmartSEMControl</Name>
     </ProjectReference>
+    <ProjectReference Include="..\WebManager\WebManager.csproj">
+      <Project>{00319b6f-fad0-46b5-b76b-7164dc5ca0d5}</Project>
+      <Name>WebManager</Name>
+    </ProjectReference>
   </ItemGroup>
   <ItemGroup>
     <None Include="Resources\exit_Gray.png" />

+ 1 - 1
WebManager/HttpRequestHelper.cs

@@ -18,7 +18,7 @@ namespace WebManager
     /// 3.请求成功后,将HttpResponseHeader.SetCookie记录下来。    
     /// 4.下次请求时,附加上第3步的cookie,即可模拟登录后操作。     
     /// </summary>    
-    public class HttpRequestHelper    
+    class HttpRequestHelper    
     {        
         /// <summary>        
         ///     cookie集合,用于模拟登陆        

BIN=BIN
WebManager/Newtonsoft.Json.dll


+ 7 - 0
WebManager/WebManager.csproj

@@ -32,6 +32,10 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>.\Newtonsoft.Json.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Xml.Linq" />
@@ -46,5 +50,8 @@
     <Compile Include="WebResult.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="Newtonsoft.Json.dll" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

+ 222 - 1
WebManager/WebResult.cs

@@ -3,11 +3,14 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
 
 namespace WebManager
 {
     public class WebResult
     {
+        #region
         /// <summary>
         /// 数据定义
         /// </summary>
@@ -18,6 +21,8 @@ namespace WebManager
         private const String Post = "Post";
         private const String Content_Type= "Content-Type:application/json";
 
+        #endregion
+
         /// <summary>
         /// 构造函数
         /// </summary>
@@ -84,7 +89,12 @@ namespace WebManager
             }
         }
 
-        public String RequestString(String postString)
+        /// <summary>
+        /// 向WebServer请求数据及返回结果
+        /// </summary>
+        /// <param name="postString">请求数据的JSON</param>
+        /// <returns>返回结果的JSON</returns>
+        private String RequestString(String postString)
         {
             try
             {
@@ -96,5 +106,216 @@ namespace WebManager
                 return "";
             }
         }
+
+        /// <summary>
+        /// 计算原始图像偏移角度及方向
+        /// </summary>
+        /// <param name="imagePath">图片路径</param>
+        /// <returns>json字符串</returns>
+        public void Img_OffsetAngle_Direction(String imagePath, out double degree, out int direction, out int state)
+        {
+            JObject json = new JObject();
+            json.Add("img_path", imagePath);
+            String res = RequestString(JsonConvert.SerializeObject(json));
+            JObject jret= (JObject)JsonConvert.DeserializeObject(res);
+
+            if (jret != null && jret.Property("img_name") != null && jret.Property("img_name").ToString() != "")
+            {
+                JObject jname = JObject.Parse(jret["img_name"].ToString());
+                degree = Convert.ToDouble(jname["degree"].ToString());
+                direction = Convert.ToInt32(jname["direction"].ToString());
+                state = Convert.ToInt32(jname["state"].ToString());
+            }
+            else
+            {
+                state = 0;
+                direction = 0;
+                degree = 0;
+            }
+
+        }
+
+        /// <summary>
+        /// 计算切割点位置
+        /// </summary>
+        /// <param name="imagePath">图片路径</param>
+        /// <returns>json字符串</returns>
+        public void Img_Cut_Position(String imagePath, out double offsetx, out double offsety, out int state)
+        {
+            JObject json = new JObject();
+            json.Add("img_path", imagePath);
+            String res = RequestString(JsonConvert.SerializeObject(json));
+            JObject jret = (JObject)JsonConvert.DeserializeObject(res);
+            if (jret != null && jret.Property("img_name") != null && jret.Property("img_name").ToString() != "")
+            {
+                JObject jname = JObject.Parse(jret["img_name"].ToString());
+                JArray jlocation = JArray.Parse(jname["location"].ToString());
+                offsetx = Convert.ToDouble(jlocation[0].ToString());
+                offsety = Convert.ToDouble(jlocation[1].ToString());
+                state = Convert.ToInt32(jname["state"].ToString());
+            }
+            else
+            {
+                state = 0;
+                offsetx = 0;
+                offsety = 0;
+            }
+        }
+
+        /// <summary>
+        /// 是否切割成功验证
+        /// </summary>
+        /// <param name="imageBefore">切割前图像路径</param>
+        /// <param name="imageAfter">切割后图像路径</param>
+        /// <returns>json字符串</returns>
+        public void Img_Cut_Success(String imageBefore, String imageAfter, out int state)
+        {
+            JObject json = new JObject();
+            json.Add("img_before_path", imageBefore);
+            json.Add("img_after_path", imageAfter);
+            String res = RequestString(JsonConvert.SerializeObject(json));
+            JObject jret = (JObject)JsonConvert.DeserializeObject(res);
+            if (jret != null && jret.Property("state") != null && jret.Property("state").ToString() != "")
+            {
+                state = Convert.ToInt32(jret["state"].ToString());
+            }
+            else
+            {
+                state = 0;
+            }
+        }
+
+        /// <summary>
+        /// 计算切割后图像梯形区域上边中心点坐标
+        /// </summary>
+        /// <param name="imagePath">图片路径</param>
+        /// <returns>json字符串</returns>
+        public void Img_Trapezoid_Top_Center_Position(String imagePath, out double offsetx, out double offsety, out int state)
+        {
+            JObject json = new JObject();
+            json.Add("img_path", imagePath);
+            String res = RequestString(JsonConvert.SerializeObject(json));
+            JObject jret = (JObject)JsonConvert.DeserializeObject(res);
+            if (jret != null && jret.Property("img_name") != null && jret.Property("img_name").ToString() != "")
+            {
+                JObject jname = JObject.Parse(jret["img_name"].ToString());
+                JArray jlocation = JArray.Parse(jname["top_center"].ToString());
+                offsetx = Convert.ToDouble(jlocation[0].ToString());
+                offsety = Convert.ToDouble(jlocation[1].ToString());
+                state = Convert.ToInt32(jname["state"].ToString());
+            }
+            else
+            {
+                state = 0;
+                offsetx = 0;
+                offsety = 0;
+            }
+        }
+
+        /// <summary>
+        /// 自动对焦
+        /// </summary>
+        /// <param name="imagePath">一组图片路径</param>
+        /// <returns>json字符串</returns>
+        public String Img_Auto_Focus(List<String> imagePath)
+        {
+            JObject json = new JObject();
+            for(int i=0;i<imagePath.Count;i++)
+            {
+                json.Add("img_path" + i.ToString(), imagePath[i]);
+            }
+            String res = RequestString(JsonConvert.SerializeObject(json));
+            JObject jret = (JObject)JsonConvert.DeserializeObject(res);
+            if (jret != null && jret.Property("img_path") != null && jret.Property("img_path").ToString() != "")
+            {
+                return jret["img_path"].ToString();
+            }
+            else
+            {
+                return "";
+            }
+        }
+
+        /// <summary>
+        /// 自动消像散
+        /// </summary>
+        /// <param name="imagePath">一组图片路径</param>
+        /// <returns>json字符串</returns>
+        public String Img_Auto_Stigmatic(List<String> imagePath)
+        {
+            JObject json = new JObject();
+            for (int i = 0; i < imagePath.Count; i++)
+            {
+                json.Add("img_path" + i.ToString(), imagePath[i]);
+            }
+            String res = RequestString(JsonConvert.SerializeObject(json));
+            JObject jret = (JObject)JsonConvert.DeserializeObject(res);
+            if (jret != null && jret.Property("img_path") != null && jret.Property("img_path").ToString() != "")
+            {
+                return jret["img_path"].ToString();
+            }
+            else
+            {
+                return "";
+            }
+        }
+
+        /// <summary>
+        /// 计算切割面区域中心坐标,以及偏移角度及方向
+        /// </summary>
+        /// <param name="imagePath">图片路径</param>
+        /// <returns>json字符串</returns>
+        public void Img_Center_Position_OffsetAngle_Direction(String imagePath, out double offsetx, out double offsety, out double degree, out int direction, out int state)
+        {
+            JObject json = new JObject();
+            json.Add("img_path", imagePath);
+            String res = RequestString(JsonConvert.SerializeObject(json));
+            JObject jret = (JObject)JsonConvert.DeserializeObject(res);
+            if (jret != null && jret.Property("img_name") != null && jret.Property("img_name").ToString() != "")
+            {
+                JObject jname = JObject.Parse(jret["img_name"].ToString());
+                JArray jlocation = JArray.Parse(jname["center"].ToString());
+                offsetx = Convert.ToDouble(jlocation[0].ToString());
+                offsety = Convert.ToDouble(jlocation[1].ToString());
+                state = Convert.ToInt32(jname["state"].ToString());
+                degree = Convert.ToDouble(jname["degree"].ToString());
+                direction = Convert.ToInt32(jname["direction"].ToString());
+
+            }
+            else
+            {
+                state = 0;
+                direction = 0;
+                degree = 0;
+                offsetx = 0;
+                offsety = 0;
+            }
+        }
+
+        /// <summary>
+        /// 测量尺寸
+        /// </summary>
+        /// <param name="imagePath">图片路径</param>
+        /// <param name="ratio">放大倍数</param>
+        /// <param name="size">一像素代表**mm/um</param>
+        /// <returns>json字符串</returns>
+        public void Img_Measure_Size(String imagePath, String ratio, String size, out int state)
+        {
+            JObject json = new JObject();
+            json.Add("img_path", imagePath);
+            json.Add("ratio", ratio);
+            json.Add("size", size);
+            String res = RequestString(JsonConvert.SerializeObject(json));
+            JObject jret = (JObject)JsonConvert.DeserializeObject(res);
+            if (jret != null && jret.Property("img_name") != null && jret.Property("img_name").ToString() != "")
+            {
+                JObject jstate = JObject.Parse(jret["img_name"].ToString());
+                state = Convert.ToInt32(jstate["state"].ToString());
+            }
+            else
+            {
+                state = 0;
+            }
+        }
     }
 }

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio