OHVDbInitializer.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. using OHV.Common.Model;
  2. using OHV.Common.Shareds;
  3. using SQLite.CodeFirst;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data.Entity;
  7. namespace OHV.SqliteDAL
  8. {
  9. public class OHVDbInitializer : SqliteDropCreateDatabaseWhenModelChanges<OHVDbContext>
  10. {
  11. public OHVDbInitializer( DbModelBuilder modelBuilder ) : base( modelBuilder, typeof( CustomHistory ) )
  12. {
  13. }
  14. protected override void Seed( OHVDbContext context )
  15. {
  16. //base.Seed( context );
  17. // Here you can seed your core data if you have any.
  18. context.Set<VehicleInfo>().Add( new VehicleInfo { VehicleID = "V0001", CurrentTag="0000", VehicleState = eVehicleState.None } );
  19. context.Set<Config>().AddRange( new List<Config>()
  20. {
  21. new Config
  22. {
  23. ID = ConstString.Addr,
  24. Name = ConstString.Addr,
  25. Value = "127.0.0.1",
  26. Desc = "OCS Address",
  27. EditTime = DateTime.Now
  28. },
  29. new Config
  30. {
  31. ID = ConstString.PortNo,
  32. Name = ConstString.PortNo,
  33. Value = "5000",
  34. Desc = "OCS Port Number",
  35. EditTime = DateTime.Now
  36. },
  37. new Config
  38. {
  39. ID = ConstString.VehicleID,
  40. Name = ConstString.VehicleID,
  41. Value = "V0001",
  42. Desc = "Vehicle ID",
  43. EditTime = DateTime.Now
  44. },
  45. new Config
  46. {
  47. ID = ConstString.OCSID,
  48. Name = ConstString.OCSID,
  49. Value = "S0",
  50. Desc = "OCS ID",
  51. EditTime = DateTime.Now
  52. },
  53. new Config
  54. {
  55. ID = ConstString.BuzzerStartReadyTime,
  56. Name = ConstString.BuzzerStartReadyTime,
  57. Value = "3000",
  58. Desc = "BeforeMoveBuzzer",
  59. EditTime = DateTime.Now
  60. },
  61. new Config
  62. {
  63. ID = ConstString.PIOInterLockTimeout,
  64. Name= ConstString.PIOInterLockTimeout,
  65. Value = "30000",
  66. Desc = "PIO InterLock Time Out",
  67. EditTime = DateTime.Now,
  68. },
  69. new Config
  70. {
  71. ID = ConstString.PIOTimeOut,
  72. Name= ConstString.PIOTimeOut,
  73. Value = "5000",
  74. Desc = "PIO Time Out",
  75. EditTime = DateTime.Now,
  76. },
  77. new Config
  78. {
  79. ID = ConstString.DriveSpeed,
  80. Name= ConstString.DriveSpeed,
  81. Value = "100",
  82. Desc = "Drive Speed",
  83. EditTime = DateTime.Now,
  84. },
  85. new Config
  86. {
  87. ID = ConstString.BatteryCanType,
  88. Name= ConstString.BatteryCanType,
  89. Value = "1",
  90. Desc = "Can Kind",
  91. EditTime = DateTime.Now,
  92. },
  93. new Config
  94. {
  95. ID = ConstString.RouteFilePath,
  96. Name= ConstString.RouteFilePath,
  97. Value = @"C:\OHV\mahaOHV\route_map\ohv_testmap7.json",
  98. Desc = "Route File Path",
  99. EditTime = DateTime.Now,
  100. },
  101. } );
  102. context.Set<AxisPositionData>().AddRange( new List<AxisPositionData>()
  103. {
  104. new AxisPositionData
  105. {
  106. AxisName = ConstString.AXIS_CARRIER_LOCK_LEFT,
  107. Name = ConstString.TEACH_POSITION_LOCK,
  108. Value = 25,
  109. },
  110. new AxisPositionData
  111. {
  112. AxisName = ConstString.AXIS_CARRIER_LOCK_LEFT,
  113. Name = ConstString.TEACH_POSITION_UNLOCK,
  114. },
  115. new AxisPositionData
  116. {
  117. AxisName = ConstString.AXIS_CARRIER_LOCK_RIGHT,
  118. Name = ConstString.TEACH_POSITION_LOCK,
  119. Value = 25,
  120. },
  121. new AxisPositionData
  122. {
  123. AxisName = ConstString.AXIS_CARRIER_LOCK_RIGHT,
  124. Name = ConstString.TEACH_POSITION_UNLOCK,
  125. },
  126. } );
  127. context.Set<AxisVelocityData>().AddRange( new List<AxisVelocityData>()
  128. {
  129. new AxisVelocityData
  130. {
  131. AxisName = ConstString.AXIS_CARRIER_LOCK_LEFT,
  132. AutoRunVelocity = 200,
  133. AutoRunAccelerate = 100,
  134. AutoRunDecelerate = 100,
  135. ManualRunVelocity = 100,
  136. JogFast = 10,
  137. JogSlow = 2,
  138. Tolerance = 1,
  139. },
  140. new AxisVelocityData
  141. {
  142. AxisName = ConstString.AXIS_CARRIER_LOCK_RIGHT,
  143. AutoRunVelocity = 200,
  144. AutoRunAccelerate = 100,
  145. AutoRunDecelerate = 100,
  146. ManualRunVelocity = 100,
  147. JogFast = 10,
  148. JogSlow = 2,
  149. Tolerance = 1,
  150. },
  151. } );
  152. context.Set<AxisConfig>().AddRange( new List<AxisConfig>()
  153. {
  154. new AxisConfig
  155. {
  156. Name = ConstString.AXIS_CARRIER_LOCK_LEFT,
  157. Scale = 0.001,
  158. Address = "192.168.0.40",
  159. },
  160. new AxisConfig
  161. {
  162. Name = ConstString.AXIS_CARRIER_LOCK_RIGHT,
  163. Scale = 0.001,
  164. Address = "192.168.0.41",
  165. }
  166. } );
  167. context.Set<Alarm>().AddRange( new List<Alarm>()
  168. {
  169. new Alarm { AlarmId = 1, Kind = eAlarmKind.Axis, Name = "LeftClampServo", Text="Left Clamp Lock Motion Error", Solution="", Description="", Level = eAlarmLevel.Falut, },
  170. new Alarm { AlarmId = 2, Kind = eAlarmKind.Axis, Name = "LeftClampServo", Text="Left Clamp Unlock Motion Error", Solution="", Description="", Level = eAlarmLevel.Falut, },
  171. new Alarm { AlarmId = 3, Kind = eAlarmKind.Axis, Name = "RightClamServo", Text="Right Clamp Lock Motion Error", Solution="", Description="", Level = eAlarmLevel.Falut, },
  172. new Alarm { AlarmId = 4, Kind = eAlarmKind.Axis, Name = "RightClamServo", Text="Right Clamp Unlock Motion Error", Solution="", Description="", Level = eAlarmLevel.Falut, },
  173. new Alarm { AlarmId = 5, Kind = eAlarmKind.Axis, Name = "RightClamServo", Text="Is Not Origin Return", Solution="", Description="", Level = eAlarmLevel.Falut, },
  174. new Alarm { AlarmId = 6, Kind = eAlarmKind.Axis, Name = "LeftClampServo", Text="Is Not Origin Return", Solution="", Description="", Level = eAlarmLevel.Falut, },
  175. new Alarm { AlarmId = 7, Kind = eAlarmKind.Axis, Name = "RightClamServo", Text="Origin Return Fail", Solution="", Description="", Level = eAlarmLevel.Falut, },
  176. new Alarm { AlarmId = 8, Kind = eAlarmKind.Axis, Name = "LeftClampServo", Text="Origin Return Fail", Solution="", Description="", Level = eAlarmLevel.Falut, },
  177. new Alarm { AlarmId = 9, Kind = eAlarmKind.Axis, Name = "Conveyor", Text="Already Exist Carrier", Solution="", Description="", Level = eAlarmLevel.Falut, },
  178. new Alarm { AlarmId = 10, Kind = eAlarmKind.Axis, Name = "Conveyor", Text="Loading Time Over", Solution="", Description="", Level = eAlarmLevel.Falut, },
  179. new Alarm { AlarmId = 11, Kind = eAlarmKind.Axis, Name = "Conveyor", Text="Not Exist Carrier", Solution="", Description="", Level = eAlarmLevel.Falut, },
  180. new Alarm { AlarmId = 12, Kind = eAlarmKind.Axis, Name = "Conveyor", Text="Unloading Time Over", Solution="", Description="", Level = eAlarmLevel.Falut, },
  181. new Alarm { AlarmId = 13, Kind = eAlarmKind.Axis, Name = "Conveyor", Text="Lifter Not Unloading Position", Solution="", Description="", Level = eAlarmLevel.Falut, },
  182. new Alarm { AlarmId = 14, Kind = eAlarmKind.Axis, Name = "Conveyor", Text="Lifter Not Loading Position", Solution="", Description="", Level = eAlarmLevel.Falut, },
  183. new Alarm { AlarmId = 15, Kind = eAlarmKind.Axis, Name = "Conveyor", Text="Lifter have not Carrier", Solution="", Description="", Level = eAlarmLevel.Falut, },
  184. new Alarm { AlarmId = 16, Kind = eAlarmKind.Axis, Name = "Conveyor", Text="Inverter Error", Solution="", Description="", Level = eAlarmLevel.Falut, },
  185. new Alarm { AlarmId = 17, Kind = eAlarmKind.Axis, Name = "PIO", Text="Port PIO Ready Off", Solution="", Description="", Level = eAlarmLevel.Falut, },
  186. new Alarm { AlarmId = 18, Kind = eAlarmKind.Axis, Name = "PIO", Text="Port PIO Time Out", Solution="", Description="", Level = eAlarmLevel.Falut, },
  187. new Alarm { AlarmId = 19, Kind = eAlarmKind.Axis, Name = "PIO", Text="Port PIO InterLock On", Solution="", Description="", Level = eAlarmLevel.Falut, },
  188. new Alarm { AlarmId = 20, Kind = eAlarmKind.Axis, Name = "Conveyor", Text="Loading Position Wrong", Solution="", Description="", Level = eAlarmLevel.Falut, },
  189. new Alarm { AlarmId = 21, Kind = eAlarmKind.Axis, Name = "Conveyor", Text="Unloading Position Wrong", Solution="", Description="", Level = eAlarmLevel.Falut, },
  190. new Alarm { AlarmId = 22, Kind = eAlarmKind.Axis, Name = "Init", Text="Vehicle Drive Error", Solution="", Description="", Level = eAlarmLevel.Falut, },
  191. new Alarm { AlarmId = 23, Kind = eAlarmKind.Axis, Name = "EStop", Text="EStop", Solution="", Description="", Level = eAlarmLevel.Falut, },
  192. new Alarm { AlarmId = 24, Kind = eAlarmKind.Axis, Name = "Vehicle Move Error", Text="while Vehicle Move Obstacle Detected",Solution="", Description="", Level = eAlarmLevel.Falut, },
  193. new Alarm { AlarmId = 25, Kind = eAlarmKind.Axis, Name = "Charge", Text="Charge Point Not Ready", Solution="", Description="", Level = eAlarmLevel.Falut, },
  194. new Alarm { AlarmId = 26, Kind = eAlarmKind.Axis, Name = "Charge", Text="Charge Point PIO Error", Solution="", Description="", Level = eAlarmLevel.Falut, },
  195. new Alarm { AlarmId = 27, Kind = eAlarmKind.Axis, Name = "Charge", Text="while Vehicle Move Obstacle Detected",Solution="", Description="", Level = eAlarmLevel.Falut, },
  196. new Alarm { AlarmId = 28, Kind = eAlarmKind.Axis, Name = "System", Text="E - Stop Switch On",Solution="", Description="", Level = eAlarmLevel.Falut, },
  197. new Alarm { AlarmId = 29, Kind = eAlarmKind.Axis, Name = "System", Text="MC Off",Solution="", Description="", Level = eAlarmLevel.Falut, },
  198. new Alarm { AlarmId = 30, Kind = eAlarmKind.Axis, Name = "System", Text="CP Off 24V",Solution="", Description="", Level = eAlarmLevel.Falut, },
  199. new Alarm { AlarmId = 31, Kind = eAlarmKind.Axis, Name = "System", Text="CP Off Safety",Solution="", Description="", Level = eAlarmLevel.Falut, },
  200. new Alarm { AlarmId = 32, Kind = eAlarmKind.Axis, Name = "BMS", Text="Battery Manage System Disconnected",Solution="", Description="", Level = eAlarmLevel.Falut, },
  201. new Alarm { AlarmId = 33, Kind = eAlarmKind.Axis, Name = "Steering", Text="Steering State Abnormal",Solution="", Description="", Level = eAlarmLevel.Falut, },
  202. new Alarm { AlarmId = 34, Kind = eAlarmKind.Drive, Name = "PIO", Text="Battery Charge PIO Not Ready On",Solution="", Description="", Level = eAlarmLevel.Falut, },
  203. new Alarm { AlarmId = 35, Kind = eAlarmKind.Drive, Name = "PIO", Text="Battery Charge PIO Not SEND_RUN On TimeOver",Solution="", Description="", Level = eAlarmLevel.Falut, },
  204. new Alarm { AlarmId = 36, Kind = eAlarmKind.Drive, Name = "PIO", Text="Battery Charge PIO Not SEND_COMPLETE On TimeOver",Solution="", Description="", Level = eAlarmLevel.Falut, },
  205. new Alarm { AlarmId = 37, Kind = eAlarmKind.Drive, Name = "PIO", Text="Steering State Abnormal",Solution="", Description="", Level = eAlarmLevel.Falut, },
  206. new Alarm { AlarmId = 38, Kind = eAlarmKind.Drive, Name = "PIO", Text="Steering State Abnormal",Solution="", Description="", Level = eAlarmLevel.Falut, },
  207. } );
  208. //context.Set<HisAlarm>().Add(new HisAlarm { AlarmId = 1, OccurTime = DateTime.Now.AddDays(-10) });
  209. context.Set<Route>().Add( new Route { Id = 1, Name = "P01", PrePoint = "P11", NextPoint = "P02", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1000", UsePIO = true } );
  210. context.Set<Route>().Add( new Route { Id = 2, Name = "P02", PrePoint = "P01", NextPoint = "P03", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1001", UsePIO = true } );
  211. context.Set<Route>().Add( new Route { Id = 3, Name = "P03", PrePoint = "P02", NextPoint = "P04", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1002", UsePIO = true } );
  212. context.Set<Route>().Add( new Route { Id = 4, Name = "P04", PrePoint = "P03", NextPoint = "P05", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1003", UsePIO = true } );
  213. context.Set<Route>().Add( new Route { Id = 5, Name = "P05", PrePoint = "P04", NextPoint = "P06", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1004", UsePIO = true } );
  214. context.Set<Route>().Add( new Route { Id = 6, Name = "P06", PrePoint = "P05", NextPoint = "P07", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1005", UsePIO = true } );
  215. context.Set<Route>().Add( new Route { Id = 7, Name = "P07", PrePoint = "P06", NextPoint = "P08", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1006", UsePIO = true } );
  216. context.Set<Route>().Add( new Route { Id = 8, Name = "P08", PrePoint = "P07", NextPoint = "P09", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1007", UsePIO = true } );
  217. context.Set<Route>().Add( new Route { Id = 9, Name = "P09", PrePoint = "P08", NextPoint = "P10", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1008", UsePIO = true } );
  218. context.Set<Route>().Add( new Route { Id = 10, Name = "P10", PrePoint = "P09", NextPoint = "P11", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1009", UsePIO = true } );
  219. context.Set<Route>().Add( new Route { Id = 11, Name = "P11", PrePoint = "P10", NextPoint = "P01", ScaleTolerance = 0.5, Form = eRoadForm.Straight, ScaleValue = 0.0, Type = ePointType.LoadPort, OCSMatchID = "1010", UsePIO = true } );
  220. }
  221. }
  222. }