InitWorkflow.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. if (plc.PLC_NAME == "srm01" || plc.PLC_NAME == "srm06")
  68. {
  69. plc.EquPlc = new SrmTray();
  70. }
  71. else
  72. {
  73. //实例化堆垛机类
  74. plc.EquPlc = new SRM_Tray();
  75. }
  76. }
  77. else if (plc.PLC_EQUIPMENTTYPE == EquipmentType.rgv.ToString())
  78. {
  79. if (plc.PLC_NAME == "rgv1195")
  80. {
  81. plc.EquPlc = new Rgv04();
  82. }
  83. else if (plc.PLC_NAME == "rgv1089" || plc.PLC_NAME == "rgv1091")
  84. {
  85. plc.EquPlc = new Rgv03();
  86. }
  87. else
  88. {
  89. plc.EquPlc = new Rgv02();
  90. }
  91. }
  92. //else if (plc.PLC_EQUIPMENTTYPE == EquipmentType.rgv.ToString())
  93. //{
  94. // if (plc.PLC_NAME == "rgv2062" || plc.PLC_NAME == "rgv2044" || plc.PLC_NAME == "rgv2029" || plc.PLC_NAME == "rgv2019" ||
  95. // plc.PLC_NAME == "rgv2189" || plc.PLC_NAME == "rgv2163" || plc.PLC_NAME == "rgv2143" || plc.PLC_NAME == "rgv2125")
  96. // {
  97. // plc.EquPlc = new Rgv02();
  98. // }
  99. //}
  100. else if (plc.PLC_EQUIPMENTTYPE == EquipmentType.conveyor.ToString())
  101. {
  102. if (plc.PLC_NAME == "conveyor01") plc.EquPlc = new ConveyorPlc01();
  103. if (plc.PLC_NAME == "conveyor02") plc.EquPlc = new ConvPlc02();
  104. if (plc.PLC_NAME == "conveyor03") plc.EquPlc = new ConvPlc03();
  105. if (plc.PLC_NAME == "conveyor04") plc.EquPlc = new ConvPlc04();
  106. }
  107. if (plc.EquPlc != null) plc.EquPlc.WCS_PLCItem = plc;
  108. }
  109. #endregion;
  110. }
  111. catch (Exception ex)
  112. {
  113. LogMessageHelper.RecordLogMessage(ex);
  114. }
  115. }
  116. }
  117. }