InitWorkflow.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using WCS.Data;
  6. using WCS.Data.Models;
  7. using WCS.Data.Utils;
  8. using WCS.PLC;
  9. using WCS.PLC.Model.Equipment;
  10. namespace WCS.Workflow
  11. {
  12. public class InitWorkflow
  13. {
  14. public static void InitData()
  15. {
  16. try
  17. {
  18. Current.InitData(BaseCurrent.WcsSystem);
  19. //var routes = EquRouteHelper.QueryRoute("2235", "2381");
  20. //var item = routes.FirstOrDefault(v => v.ROUTE_STARTPOS == "2235");
  21. //int num1 = 1512;
  22. //int num2 = 1520;
  23. //int index = 511;
  24. //for (int temp = num1; temp <= num2; temp++)
  25. //{
  26. // var equipment = new WCS_EQUIPMENTINFO();
  27. // equipment.Equ_Id = Guid.NewGuid().ToString("N");
  28. // equipment.Equ_No = temp.ToString();
  29. // equipment.Equ_PlcName = "conveyor02";
  30. // equipment.Equ_Sequence = index;
  31. // equipment.Equ_Area = "A";
  32. // equipment.Equ_Type = "conveyor";
  33. // equipment.Equ_ReadWriteDB_Sequence = index.ToString();
  34. // equipment.Equ_ReadWriteDB_Length = 22;
  35. // equipment.Equ_ReadDB_Sequence = index.ToString();
  36. // equipment.Equ_ReadDB_Length = 22;
  37. // equipment.Equ_StatusDB_Sequence = index.ToString();
  38. // equipment.Equ_StatusDB_Length = 10;
  39. // //if (temp == 2235)
  40. // //{
  41. // // equipment.Equ_BarCodeDB_Sequence = "0";
  42. // // equipment.Equ_BarCodeDB_Length = 80;
  43. // //}
  44. // //else if (temp == 2238)
  45. // //{
  46. // // equipment.Equ_BarCodeDB_Sequence = "1";
  47. // // equipment.Equ_BarCodeDB_Length = 80;
  48. // //}
  49. // //else if (temp == 2246)
  50. // //{
  51. // // equipment.Equ_BarCodeDB_Sequence = "2";
  52. // // equipment.Equ_BarCodeDB_Length = 80;
  53. // //}
  54. // //else if (temp == 2359)
  55. // //{
  56. // // equipment.Equ_BarCodeDB_Sequence = "3";
  57. // // equipment.Equ_BarCodeDB_Length = 80;
  58. // //}
  59. // SugarBase.DB.Insertable(equipment).ExecuteCommand();
  60. // index++;
  61. //}
  62. #region 实例化堆垛机,输送机,穿梭车
  63. foreach (var plc in Current.PlcSet)
  64. {
  65. if (plc.PLC_EQUIPMENTTYPE == EquipmentType.srm.ToString())
  66. {
  67. //实例化堆垛机类
  68. plc.EquPlc = new SRM_Tray();
  69. }
  70. else if (plc.PLC_EQUIPMENTTYPE == EquipmentType.rgv.ToString())
  71. {
  72. if (plc.PLC_NAME == "rgv1195")
  73. {
  74. plc.EquPlc = new Rgv04();
  75. }
  76. else if (plc.PLC_NAME == "rgv1089" || plc.PLC_NAME == "rgv1091")
  77. {
  78. plc.EquPlc = new Rgv03();
  79. }
  80. else
  81. {
  82. plc.EquPlc = new Rgv02();
  83. }
  84. }
  85. //else if (plc.PLC_EQUIPMENTTYPE == EquipmentType.rgv.ToString())
  86. //{
  87. // if (plc.PLC_NAME == "rgv2062" || plc.PLC_NAME == "rgv2044" || plc.PLC_NAME == "rgv2029" || plc.PLC_NAME == "rgv2019" ||
  88. // plc.PLC_NAME == "rgv2189" || plc.PLC_NAME == "rgv2163" || plc.PLC_NAME == "rgv2143" || plc.PLC_NAME == "rgv2125")
  89. // {
  90. // plc.EquPlc = new Rgv02();
  91. // }
  92. //}
  93. else if (plc.PLC_EQUIPMENTTYPE == EquipmentType.conveyor.ToString())
  94. {
  95. if (plc.PLC_NAME == "conveyor01") plc.EquPlc = new ConveyorPlc01();
  96. if (plc.PLC_NAME == "conveyor02") plc.EquPlc = new ConvPlc02();
  97. if (plc.PLC_NAME == "conveyor03") plc.EquPlc = new ConvPlc03();
  98. if (plc.PLC_NAME == "conveyor04") plc.EquPlc = new ConvPlc04();
  99. }
  100. if (plc.EquPlc != null) plc.EquPlc.WCS_PLCItem = plc;
  101. }
  102. #endregion;
  103. }
  104. catch (Exception ex)
  105. {
  106. LogMessageHelper.RecordLogMessage(ex);
  107. }
  108. }
  109. }
  110. }