MitsubishiServer.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using EZSockets;
  2. using RequestServer.HttpServer;
  3. using ResponseServer.HttpServer;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Net.NetworkInformation;
  8. using System.Text;
  9. using System.Threading;
  10. using System.Threading.Tasks;
  11. namespace HttpServer.mitsubishi
  12. {
  13. class MitsubishiServer
  14. {
  15. private static string ON_LINE_STATE = "在线";
  16. public static Dictionary<string, MitCom> deviceList { get; set; } = new Dictionary<string, MitCom>();
  17. public ResponseBody requestHttpServer(RequestBody<ToolData> requestBody)
  18. {
  19. string ip = requestBody.serverUrl;
  20. string port = requestBody.port;
  21. string fun = requestBody.type;
  22. ResponseBody responseBody = new ResponseBody();
  23. //先ping
  24. Ping pingSender = new Ping();
  25. PingReply reply = pingSender.Send(requestBody.serverUrl);
  26. if (reply.Status != IPStatus.Success)
  27. {
  28. //responseBody.result = true;
  29. responseBody.msg = "调用失败";
  30. }
  31. else
  32. {
  33. try
  34. {
  35. MitCom mitCom = new MitCom(requestBody.serverUrl);
  36. mitCom.GetSimConnect("M700M", "1", "10", ip);
  37. responseBody.deviceState = ON_LINE_STATE;
  38. if (fun == ActionTypeEnum.Collect.ToString())
  39. {
  40. }
  41. }
  42. catch (Exception e)
  43. {
  44. responseBody.msg = "调用失败";
  45. YG.Log.Instance.WriteLogAdd($"三菱连接结果-ex-->> " + e.Message);
  46. //deviceList.Remove(requestBody.serverUrl);
  47. }
  48. }
  49. return responseBody;
  50. }
  51. }
  52. }