FanucServer.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using FANUC;
  2. using fanuc采集;
  3. using HttpServer;
  4. using RequestServer.HttpServer;
  5. using ResponseServer.HttpServer;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using static fanuc采集.ConDevice;
  12. using static HttpServer.Form1;
  13. namespace Fanuc_HttpServer.fanuc
  14. {
  15. class FanucServer
  16. {
  17. private static string ON_LINE_STATE = "在线";
  18. public static ResponseBody requestHttpServer(RequestBody<ToolData> requestBody)
  19. {
  20. string ip = requestBody.serverUrl;
  21. string port = requestBody.port;
  22. string fun = requestBody.type;
  23. int ret = 0;
  24. ConDevice CIF = new ConDevice();
  25. ResponseBody responseBody = new ResponseBody();
  26. if (fun == ActionTypeEnum.Collect.ToString())
  27. {
  28. ConDevice2 CIF2 = new ConDevice2(ip, port);
  29. }
  30. else if (fun == ActionTypeEnum.Upload.ToString())
  31. {
  32. try
  33. {
  34. string prgname = requestBody.prgName;
  35. YG.Log.Instance.WriteLogAdd(">>>===上传文件名 : >>>>===" + prgname);
  36. ret = CIF.UploadNcProg(ip, port, prgname);
  37. if (ret == Fanuc.EW_OK)
  38. {
  39. responseBody.deviceState = ON_LINE_STATE;
  40. }
  41. else
  42. {
  43. responseBody.msg = "上传文件名失败,错误码:" + ret;
  44. }
  45. }
  46. catch (Exception uploadex)
  47. {
  48. responseBody.msg = "上传文件名" + uploadex.Message;
  49. }
  50. }
  51. else if (fun == ActionTypeEnum.StartNcProgram.ToString())
  52. {
  53. try
  54. {
  55. string prgname = requestBody.prgName;
  56. ret = CIF.ReadPmcMarco(ip, port, prgname);
  57. if (ret == Fanuc.EW_OK)
  58. {
  59. responseBody.deviceState = ON_LINE_STATE;
  60. }
  61. else
  62. {
  63. responseBody.msg = "调用失败";
  64. }
  65. }
  66. catch (Exception uploadex)
  67. {
  68. responseBody.msg = "调用失败" + uploadex.Message;
  69. }
  70. }
  71. else if (fun == ActionTypeEnum.AlmInfo.ToString())
  72. {
  73. }
  74. return responseBody;
  75. }
  76. }
  77. }