Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.71 KB | None | 0 0
  1. begin model initialization function
  2. //create a load who will start the code
  3. create 1 load of load type L_Init to P_Init
  4. return 0
  5. end
  6.  
  7. begin P_Init arriving procedure
  8.  
  9. /* Variables */
  10.  
  11. set VI_PaintingBatchSize = 10
  12.  
  13. /* Set cycle times for Cutters */
  14. //Triagular min, mode,max
  15. set VI_CycleTimeCutter(1,1) = 5
  16. set VI_CycleTimeCutter(1,2) = 8
  17. set VI_CycleTimeCutter(1,3) = 10
  18.  
  19. //Triagular min, mode,max
  20. set VI_CycleTimeCutter(2,1) = 5
  21. set VI_CycleTimeCutter(2,2) = 8
  22. set VI_CycleTimeCutter(2,3) = 9
  23.  
  24. /* Set setup times for Cutters */
  25. //Normal mean, std
  26. set VI_SetupCutter(1,1) = 240
  27. set VI_SetupCutter(1,2) = 7
  28. set VI_SetupCutter(2,1) = 260
  29. set VI_SetupCutter(2,2) = 5
  30. set VI_ArrivingTime(1) = 85
  31. set VI_ArrivingTime(2) = 80
  32.  
  33. /* Buffer capacities */
  34.  
  35. //Dummy buffer
  36. set Q_DummyPainting capacity = VI_PaintingBatchSize -1
  37. set Q_PaintingUnloading capacity = VI_PaintingBatchSize
  38. set Q_Painting capacity = 1
  39.  
  40. //Buffer lathes
  41. set Q_BufferLathe(1) capacity = 2
  42. set Q_BufferLathe(2) capacity = Q_BufferLathe(1) capacity
  43. set Q_BufferLathe(3) capacity = Q_BufferLathe(1) capacity
  44.  
  45. //Buffer cutting
  46. set Q_BufferCutter(1) capacity = 4
  47. set Q_BufferCutter(2) capacity = Q_BufferCutter(1) capacity
  48.  
  49. //Buffer painting
  50. set Q_BufferPainting capacity = 4
  51.  
  52. //send load to creation process
  53. create 1 load of load type L_TubeA to P_Creation
  54. create 1 load of load type L_TubeB to P_Creation
  55. //Dummy breakdown loads
  56. create 1 load of load type L_DummyBreakdown to P_DownTimePainting
  57. create 2 load of load type L_DummyBreakdown to P_DownTimeCutters
  58. create 3 load of load type L_DummyBreakdown to P_DownTimeLathe
  59. end
  60.  
  61. begin P_DownTimePainting arriving procedure
  62. move into Q_Supervisor
  63. while 1=1 do begin
  64. wait for normal 10, 0.5 hr //MTTF
  65. take down R_Painting
  66. wait for normal 20, 3.9 min //MTTR
  67. bring up R_Painting
  68. end
  69. end
  70.  
  71. begin P_DownTimeCutters arriving procedure
  72. move into Q_Supervisor
  73. set AI_CutterIndex to nextof(1,2)
  74. while 1=1 do begin
  75. wait for e 6 hr //MTTF
  76. take down R_Cutter(AI_CutterIndex)
  77. wait for triangular 15,25,40 min //MTTR
  78. bring up R_Cutter(AI_CutterIndex)
  79. end
  80. end
  81.  
  82. begin P_DownTimeLathe arriving procedure
  83. move into Q_Supervisor
  84. set AI_LatheIndex to nextof(1,2,3)
  85. while 1=1 do begin
  86. wait for normal 3.5, 0.2 hr //MTTF
  87. take down R_Lathe(AI_LatheIndex)
  88. wait for normal 10, 1.9 min //MTTR
  89. bring up R_Lathe(AI_LatheIndex)
  90. end
  91. end
  92.  
  93. begin P_Creation arriving procedure
  94. if this load type = L_TubeA then
  95. set AI_Type = 1
  96. else
  97. set AI_Type = 2
  98. //Create loads to P_Cutting
  99. while 1=1 begin
  100. clone 1 load to P_Cutting
  101. wait for VI_ArrivingTime(AI_Type) min
  102. end
  103. end
  104.  
  105. begin P_Cutting arriving procedure
  106.  
  107. /* choose the queue with the minimum number of loads */
  108. /*
  109. choose a queue from among Q_BufferCutter(1), Q_BufferCutter(2)
  110. whose current loads is minimum
  111. save choice as A_QptrCutter
  112. */
  113.  
  114. if AI_Type = 1
  115. set A_QptrCutter = Q_BufferCutter(1)
  116.  
  117. else
  118. set A_QptrCutter = Q_BufferCutter(2)
  119.  
  120. move into A_QptrCutter
  121. set AI_CutterIndex = A_QptrCutter index
  122. move into Q_Cutter(AI_CutterIndex)
  123.  
  124. /* setup time if needed */
  125. if VI_PrevType (AI_CutterIndex) != AI_Type then
  126. use R_Cutter(AI_CutterIndex) for normal
  127. VI_SetupCutter(AI_Type,1), VI_SetupCutter(AI_Type,2) sec
  128.  
  129. /* cutting process */
  130. while AI_Cuts < 10 do begin
  131. use R_Cutter(AI_CutterIndex) for triangular
  132. VI_CycleTimeCutter(AI_Type,1), VI_CycleTimeCutter(AI_Type,2), VI_CycleTimeCutter(AI_Type,3) min
  133. if Q_BufferPainting remaining space < 1 then
  134. wait to be ordered on OL_PaintBufferFull
  135. create 1 load of type L_Product to P_Painting
  136. inc AI_Cuts by 1
  137. end
  138.  
  139. /* update previous type */
  140. set VI_PrevType (AI_CutterIndex) = AI_Type
  141.  
  142. /* The tube finished after being cut into 10 parts */
  143. send to die
  144. end
  145.  
  146. begin P_Painting arriving procedure
  147. move into Q_BufferPainting
  148. //Batching
  149. if OL_WaitBatchPainting current < VI_PaintingBatchSize - 1 then begin
  150. //collect batch on OL
  151. move into Q_DummyPainting
  152. //collect loads on dummy queue
  153. wait to be ordered on OL_WaitBatchPainting
  154.  
  155. wait to be ordered on OL_BatchWaitForPainting
  156. move into Q_PaintingUnloading
  157. order 1 load from OL_PaintBufferFull to continue
  158. //when painting is done
  159. //order 1 load from OL_PaintBufferFull to continue
  160. send to P_Lathes
  161. end
  162. //order the rest of the batch, so they are not available for another batch
  163. order VI_PaintingBatchSize -1 from OL_WaitBatchPainting to continue
  164. move into Q_Painting
  165. //order 1 load from OL_PaintBufferFull to continue
  166.  
  167. /* setup time */
  168. use R_Painting for uniform 85, 15 sec
  169. /* cycle time */
  170. use R_Painting for normal 3, 0.2 * VI_PaintingBatchSize min
  171. //batch done
  172.  
  173. //look if any product from previous batch is in unloading
  174. if Q_PaintingUnloading remaining space < VI_PaintingBatchSize then begin
  175. wait to be ordered on OL_PaintingUnloading
  176. end
  177. move into Q_PaintingUnloading
  178. order 1 load from OL_PaintBufferFull to continue
  179. //order the rest of the batch to continue
  180. order VI_PaintingBatchSize -1 loads from OL_BatchWaitForPainting to continue
  181. send to P_Lathes
  182. end
  183.  
  184. begin P_Lathes arriving procedure
  185.  
  186.  
  187. /* choose the Lathe which is least busy */
  188. choose a queue from among Q_BufferLathe(1), Q_BufferLathe(2), Q_BufferLathe(3)
  189. whose current loads is minimum
  190. save choice as A_QptrLathe
  191. move into A_QptrLathe
  192.  
  193. if Q_PaintingUnloading current = 0 then begin
  194. order 1 load from OL_PaintingUnloading to continue
  195. end
  196. set AI_LatheIndex = A_QptrLathe index
  197. move into Q_Lathe(AI_LatheIndex)
  198.  
  199.  
  200.  
  201. /* processing time */
  202. use R_Lathe(AI_LatheIndex) for triangular 10, 12, 17 min
  203. move into Q_Final
  204.  
  205. /* the product is finished */
  206. send to die
  207. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement