PLC_Server.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. //自动识别模块 xuwei add 2022-03-12=====================
  26. case "GA":
  27. ServerSocket = new GoodsAuto();
  28. break;
  29. //======================================================
  30. // 产品型号
  31. case "GC":
  32. ServerSocket = new GoodsCode();
  33. break;
  34. // 工序计件
  35. case "PW":
  36. ServerSocket = new PieceWork();
  37. break;
  38. // 打磨【房号+计件】
  39. case "EPTS_GP":
  40. ServerSocket = new EPTS_GoodsPolish();
  41. ServerSocket.EPTS_CODE = PLC_S_S.EPTS_CODE;
  42. ServerSocket.Interval = PLC_S_S.Interval;
  43. break;
  44. //// 条码打印
  45. //case "BP":
  46. // ServerSocket = new BarcodePrint();
  47. // break;
  48. //// 高压注浆
  49. //case "HPG":
  50. // ServerSocket = new HighPressureGrouting();
  51. // break;
  52. //// 登窑
  53. //case "KL":
  54. // ServerSocket = new KilnLoad();
  55. // break;
  56. //// 入窑
  57. //case "KI":
  58. // ServerSocket = new KilnInput();
  59. // break;
  60. //// 卸窑
  61. //case "KUL":
  62. // ServerSocket = new KilnUnLoad();
  63. // break;
  64. default:
  65. throw new NotImplementedException(PLC_S_S.PLCServiceType);
  66. }
  67. ServerSocket.Start(PLC_S_S.Port);
  68. return;
  69. }
  70. public static void Stop()
  71. {
  72. ServerSocket?.Stop();
  73. ServerSocket?.Dispose();
  74. ServerSocket = null;
  75. }
  76. }
  77. }