zhuhao 1 year ago
parent
commit
7e71d0a80e
1 changed files with 9 additions and 30 deletions
  1. 9 30
      deviceHttpServer/mitsubishi/MitsubishiServer.cs

+ 9 - 30
deviceHttpServer/mitsubishi/MitsubishiServer.cs

@@ -22,10 +22,9 @@ namespace HttpServer.mitsubishi
             string port = requestBody.port;
             string fun = requestBody.type; 
             
-            ResponseBody responseBody = new ResponseBody();
-               MitCom mitCom = null;
-        //先ping
-        Ping pingSender = new Ping();
+            ResponseBody responseBody = new ResponseBody(); 
+            //先ping
+            Ping pingSender = new Ping();
             PingReply reply = pingSender.Send(requestBody.serverUrl);
             if (reply.Status != IPStatus.Success)
             {
@@ -33,31 +32,11 @@ namespace HttpServer.mitsubishi
                 responseBody.msg = "调用失败";
             }
             else
-            {
-                if (deviceList == null || (deviceList.Where(m => m.Key == requestBody.serverUrl).Count() == 0))
-                {
-                    try
-                    {
-                        mitCom = new MitCom(requestBody.serverUrl);
-                        mitCom.GetSimConnect("M700M", "1", "10", requestBody.serverUrl);
-                        //deviceList.Add(requestBody.serverUrl, mitCom); 
-                        responseBody.deviceState = ON_LINE_STATE;
-                    }
-                    catch (Exception e)
-                    {
-                        YG.Log.Instance.WriteLogAdd($"三菱连接结果-ex-->> " + e.Message);
-                    }
-
-                    Thread.Sleep(100);
-                }
-                else
-                {
-                    mitCom = deviceList.Where(m => m.Key == requestBody.serverUrl).FirstOrDefault().Value;
-                }
-                if (mitCom != null)
-                {
+            { 
                     try
                     {
+                        MitCom mitCom = new MitCom(requestBody.serverUrl);
+                        mitCom.GetSimConnect("M700M", "1", "10", ip);
                         responseBody.deviceState = ON_LINE_STATE;
                         if (fun == ActionTypeEnum.Collect.ToString())
                         {
@@ -91,11 +70,11 @@ namespace HttpServer.mitsubishi
                     }
                     catch (Exception e)
                     {
+                        responseBody.msg = "调用失败";
                         YG.Log.Instance.WriteLogAdd($"三菱连接结果-ex-->> " + e.Message);
-                        deviceList.Remove(requestBody.serverUrl);
+                        //deviceList.Remove(requestBody.serverUrl);
                     }
-
-                }
+                 
             } 
             
             return responseBody;