WorkStart.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using ServiceCenter;
  2. using ServiceCenter.SqlSugars;
  3. using WCS.Core;
  4. using WCS.Entity.Protocol;
  5. using WCS.Entity.Protocol.BCR;
  6. using WCS.Entity.Protocol.HUB;
  7. using WCS.Entity.Protocol.RGV;
  8. using WCS.Entity.Protocol.Robot;
  9. using WCS.Entity.Protocol.SRM;
  10. using WCS.Entity.Protocol.Station;
  11. using WCS.Entity.Protocol.Truss;
  12. using WCS.WorkEngineering.Extensions;
  13. using DeviceFlags = WCS.WorkEngineering.Extensions.DeviceFlags;
  14. namespace WCS.WorkEngineering
  15. {
  16. /// <summary>
  17. /// 业务工程配置信息
  18. /// </summary>
  19. public static class WorkStart
  20. {
  21. /// <summary>
  22. /// 初始化 设备信息
  23. /// </summary>
  24. public static void InitializeDeviceInfo()
  25. {
  26. var conv = new Device("1");
  27. conv.AddFlag(DeviceFlags.输送机);
  28. conv.AddProtocol<IStation520>(0, 520, "1");
  29. }
  30. /// <summary>
  31. /// 初始化数据库连接
  32. /// </summary>
  33. /// <param name="datas"></param>
  34. public static void InitDB(this List<DataBaseConnectionString> datas)
  35. {
  36. //初始化数据库
  37. SqlSugarHelper.Do(db =>
  38. {
  39. foreach (var connectionString in datas!)
  40. {
  41. var _db = db.Connect.GetConnectionScope(connectionString.Key);
  42. switch (connectionString.Key)
  43. {
  44. case "WCSDB"://WCS基本数据库
  45. //SqlSugarHelper.SetDefault(connectionString.Key);
  46. //_db.CodeFirst.InitTables(typeof(WCS_PlcData));
  47. //_db.CodeFirst.InitTables(typeof(WCS_TaskInfo));
  48. //_db.CodeFirst.InitTables(typeof(WCS_TaskDtl));
  49. //_db.CodeFirst.InitTables(typeof(WCS_TaskOld));
  50. //_db.CodeFirst.InitTables(typeof(WCS_AgvTaskInfo));
  51. //_db.CodeFirst.InitTables(typeof(WCS_Palletizing));
  52. //_db.CodeFirst.InitTables(typeof(WCS_PalletizingLayer));
  53. //_db.CodeFirst.InitTables(typeof(WCS_PalletizingRow));
  54. //_db.CodeFirst.InitTables(typeof(WCS_PalletizingLoc));
  55. //_db.CodeFirst.InitTables(typeof(WCS_CacheLine));
  56. //_db.CodeFirst.InitTables(typeof(WCS_CacheLineLoc));
  57. break;
  58. case "WCSDlog"://WCS日志数据库
  59. break;
  60. case "PLC"://PLC
  61. SqlSugarHelper.SetPLC(connectionString.Key);
  62. _db.DbMaintenance.CreateDatabase();
  63. _db.CodeFirst.InitTables<WCS_Log>();
  64. _db.CodeFirst.InitTables<WCS_SRM520>();
  65. _db.CodeFirst.InitTables<DevRunInfo>();
  66. _db.CodeFirst.InitTables<WCS_SRM521>();
  67. _db.CodeFirst.InitTables<WCS_SRM537>();
  68. _db.CodeFirst.InitTables<WCS_RGV520>();
  69. _db.CodeFirst.InitTables<WCS_RGV521>();
  70. _db.CodeFirst.InitTables<WCS_BCR80>();
  71. _db.CodeFirst.InitTables<WCS_BCR81>();
  72. _db.CodeFirst.InitTables<WCS_BCR83>();
  73. _db.CodeFirst.InitTables<WCS_Station520>();
  74. _db.CodeFirst.InitTables<WCS_Station521>();
  75. _db.CodeFirst.InitTables<WCS_Station523>();
  76. _db.CodeFirst.InitTables<WCS_Station524>();
  77. _db.CodeFirst.InitTables<WCS_Station525>();
  78. _db.CodeFirst.InitTables<WCS_Station90>();
  79. _db.CodeFirst.InitTables<WCS_Station91>();
  80. _db.CodeFirst.InitTables<WCS_Truss520>();
  81. _db.CodeFirst.InitTables<WCS_Truss521>();
  82. _db.CodeFirst.InitTables<WCS_Truss523>();
  83. _db.CodeFirst.InitTables<WCS_Truss530>();
  84. _db.CodeFirst.InitTables<WCS_Truss531>();
  85. _db.CodeFirst.InitTables<WCS_Robot520>();
  86. _db.CodeFirst.InitTables<WCS_Robot521>();
  87. _db.CodeFirst.InitTables<WCS_Robot522>();
  88. _db.CodeFirst.InitTables<WCS_Robot530>();
  89. _db.CodeFirst.InitTables<WCS_Robot531>();
  90. var a = false;
  91. break;
  92. default: //其他库
  93. break;
  94. };
  95. };
  96. });
  97. }
  98. }
  99. public class DevDbConfig<T>
  100. {
  101. public DevDbConfig()
  102. {
  103. }
  104. public DevDbConfig(string ip, T code)
  105. {
  106. IP = ip;
  107. Code = code;
  108. }
  109. public DevDbConfig(string ip, List<DevInterval<T>> devIntervalList)
  110. {
  111. IP = ip;
  112. DevIntervalList = devIntervalList;
  113. }
  114. public DevDbConfig(string ip, List<T> devCodeList)
  115. {
  116. IP = ip;
  117. DevCodeList = devCodeList;
  118. }
  119. public string IP { get; set; }
  120. public T Code { get; set; }
  121. public T StartCode { get; set; }
  122. public T EndCode { get; set; }
  123. public List<T> DevCodeList { get; set; }
  124. public List<DevInterval<T>> DevIntervalList { get; set; }
  125. }
  126. public class DevInterval<T>
  127. {
  128. public DevInterval(T s, T e)
  129. {
  130. StartCode = s;
  131. EndCode = e;
  132. }
  133. public T StartCode { get; set; }
  134. public T EndCode { get; set; }
  135. }
  136. }