PLC_Server.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. 
  2. using System;
  3. using Curtain.Net.Sockets.PLC;
  4. using PLC_S.EPTS;
  5. using PLC_S.ServerModel;
  6. namespace PLC_S
  7. {
  8. public class PLC_Server
  9. {
  10. public static PLC_S_S PLC_S_S = null;
  11. public static IWindowsServer ServerSocket = null;
  12. public static void Start()
  13. {
  14. try
  15. {
  16. if (ServerSocket != null)
  17. {
  18. Stop();
  19. }
  20. }
  21. catch { }
  22. PLC_S_S = PLC_S_S.Get();
  23. switch (PLC_S_S.PLCServiceType)
  24. {
  25. //自动调用API接口模块 xuwei add 2023-07-24
  26. case "AA":
  27. ServerSocket = new ApiAuto();
  28. break;
  29. //======================================================
  30. //自动识别模块 xuwei add 2022-03-12=====================
  31. case "GA":
  32. ServerSocket = new GoodsAuto();
  33. break;
  34. //======================================================
  35. // 自动轮询任务 xuwei add 2022-04-18
  36. case "EPTS_GA":
  37. ServerSocket = new EPTS_GoodsAuto();
  38. ServerSocket.EPTS_CODE = PLC_S_S.EPTS_CODE;
  39. ServerSocket.Interval = PLC_S_S.Interval;
  40. break;
  41. //======================================================
  42. // 自动设备参数轮询任务 xuwei add 2022-05-21
  43. case "EPTS_DA":
  44. ServerSocket = new EPTS_DeviceAuto();
  45. ServerSocket.EPTS_CODE = PLC_S_S.EPTS_CODE;
  46. ServerSocket.Interval = PLC_S_S.Interval;
  47. break;
  48. //======================================================
  49. // 打磨【房号+计件】
  50. //case "EPTS_GP":
  51. // ServerSocket = new EPTS_GoodsPolish();
  52. // ServerSocket.EPTS_CODE = PLC_S_S.EPTS_CODE;
  53. // ServerSocket.Interval = PLC_S_S.Interval;
  54. // break;
  55. //// 条码打印
  56. //case "BP":
  57. // ServerSocket = new BarcodePrint();
  58. // break;
  59. //// 高压注浆
  60. //case "HPG":
  61. // ServerSocket = new HighPressureGrouting();
  62. // break;
  63. //// 登窑
  64. //case "KL":
  65. // ServerSocket = new KilnLoad();
  66. // break;
  67. //// 入窑
  68. //case "KI":
  69. // ServerSocket = new KilnInput();
  70. // break;
  71. //// 卸窑
  72. //case "KUL":
  73. // ServerSocket = new KilnUnLoad();
  74. // break;
  75. default:
  76. throw new NotImplementedException(PLC_S_S.PLCServiceType);
  77. }
  78. ServerSocket.Start(PLC_S_S.Port);
  79. return;
  80. }
  81. public static void Stop()
  82. {
  83. ServerSocket?.Stop();
  84. ServerSocket?.Dispose();
  85. ServerSocket = null;
  86. }
  87. }
  88. }