Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- begin model initialization function
- //create a load who will start the code
- create 1 load of load type L_Init to P_Init
- return 0
- end
- begin P_Init arriving procedure
- /* Variables */
- set VI_PaintingBatchSize = 10
- /* Set cycle times for Cutters */
- //Triagular min, mode,max
- set VI_CycleTimeCutter(1,1) = 5
- set VI_CycleTimeCutter(1,2) = 8
- set VI_CycleTimeCutter(1,3) = 10
- //Triagular min, mode,max
- set VI_CycleTimeCutter(2,1) = 5
- set VI_CycleTimeCutter(2,2) = 8
- set VI_CycleTimeCutter(2,3) = 9
- /* Set setup times for Cutters */
- //Normal mean, std
- set VI_SetupCutter(1,1) = 240
- set VI_SetupCutter(1,2) = 7
- set VI_SetupCutter(2,1) = 260
- set VI_SetupCutter(2,2) = 5
- set VI_ArrivingTime(1) = 85
- set VI_ArrivingTime(2) = 80
- /* Buffer capacities */
- //Dummy buffer
- set Q_DummyPainting capacity = VI_PaintingBatchSize -1
- set Q_PaintingUnloading capacity = VI_PaintingBatchSize
- set Q_Painting capacity = 1
- //Buffer lathes
- set Q_BufferLathe(1) capacity = 2
- set Q_BufferLathe(2) capacity = Q_BufferLathe(1) capacity
- set Q_BufferLathe(3) capacity = Q_BufferLathe(1) capacity
- //Buffer cutting
- set Q_BufferCutter(1) capacity = 4
- set Q_BufferCutter(2) capacity = Q_BufferCutter(1) capacity
- //Buffer painting
- set Q_BufferPainting capacity = 4
- //send load to creation process
- create 1 load of load type L_TubeA to P_Creation
- create 1 load of load type L_TubeB to P_Creation
- //Dummy breakdown loads
- create 1 load of load type L_DummyBreakdown to P_DownTimePainting
- create 2 load of load type L_DummyBreakdown to P_DownTimeCutters
- create 3 load of load type L_DummyBreakdown to P_DownTimeLathe
- end
- begin P_DownTimePainting arriving procedure
- move into Q_Supervisor
- while 1=1 do begin
- wait for normal 10, 0.5 hr //MTTF
- take down R_Painting
- wait for normal 20, 3.9 min //MTTR
- bring up R_Painting
- end
- end
- begin P_DownTimeCutters arriving procedure
- move into Q_Supervisor
- set AI_CutterIndex to nextof(1,2)
- while 1=1 do begin
- wait for e 6 hr //MTTF
- take down R_Cutter(AI_CutterIndex)
- wait for triangular 15,25,40 min //MTTR
- bring up R_Cutter(AI_CutterIndex)
- end
- end
- begin P_DownTimeLathe arriving procedure
- move into Q_Supervisor
- set AI_LatheIndex to nextof(1,2,3)
- while 1=1 do begin
- wait for normal 3.5, 0.2 hr //MTTF
- take down R_Lathe(AI_LatheIndex)
- wait for normal 10, 1.9 min //MTTR
- bring up R_Lathe(AI_LatheIndex)
- end
- end
- begin P_Creation arriving procedure
- if this load type = L_TubeA then
- set AI_Type = 1
- else
- set AI_Type = 2
- //Create loads to P_Cutting
- while 1=1 begin
- clone 1 load to P_Cutting
- wait for VI_ArrivingTime(AI_Type) min
- end
- end
- begin P_Cutting arriving procedure
- /* choose the queue with the minimum number of loads */
- /*
- choose a queue from among Q_BufferCutter(1), Q_BufferCutter(2)
- whose current loads is minimum
- save choice as A_QptrCutter
- */
- if AI_Type = 1
- set A_QptrCutter = Q_BufferCutter(1)
- else
- set A_QptrCutter = Q_BufferCutter(2)
- move into A_QptrCutter
- set AI_CutterIndex = A_QptrCutter index
- move into Q_Cutter(AI_CutterIndex)
- /* setup time if needed */
- if VI_PrevType (AI_CutterIndex) != AI_Type then
- use R_Cutter(AI_CutterIndex) for normal
- VI_SetupCutter(AI_Type,1), VI_SetupCutter(AI_Type,2) sec
- /* cutting process */
- while AI_Cuts < 10 do begin
- use R_Cutter(AI_CutterIndex) for triangular
- VI_CycleTimeCutter(AI_Type,1), VI_CycleTimeCutter(AI_Type,2), VI_CycleTimeCutter(AI_Type,3) min
- if Q_BufferPainting remaining space < 1 then
- wait to be ordered on OL_PaintBufferFull
- create 1 load of type L_Product to P_Painting
- inc AI_Cuts by 1
- end
- /* update previous type */
- set VI_PrevType (AI_CutterIndex) = AI_Type
- /* The tube finished after being cut into 10 parts */
- send to die
- end
- begin P_Painting arriving procedure
- move into Q_BufferPainting
- //Batching
- if OL_WaitBatchPainting current < VI_PaintingBatchSize - 1 then begin
- //collect batch on OL
- move into Q_DummyPainting
- //collect loads on dummy queue
- wait to be ordered on OL_WaitBatchPainting
- wait to be ordered on OL_BatchWaitForPainting
- move into Q_PaintingUnloading
- order 1 load from OL_PaintBufferFull to continue
- //when painting is done
- //order 1 load from OL_PaintBufferFull to continue
- send to P_Lathes
- end
- //order the rest of the batch, so they are not available for another batch
- order VI_PaintingBatchSize -1 from OL_WaitBatchPainting to continue
- move into Q_Painting
- //order 1 load from OL_PaintBufferFull to continue
- /* setup time */
- use R_Painting for uniform 85, 15 sec
- /* cycle time */
- use R_Painting for normal 3, 0.2 * VI_PaintingBatchSize min
- //batch done
- //look if any product from previous batch is in unloading
- if Q_PaintingUnloading remaining space < VI_PaintingBatchSize then begin
- wait to be ordered on OL_PaintingUnloading
- end
- move into Q_PaintingUnloading
- order 1 load from OL_PaintBufferFull to continue
- //order the rest of the batch to continue
- order VI_PaintingBatchSize -1 loads from OL_BatchWaitForPainting to continue
- send to P_Lathes
- end
- begin P_Lathes arriving procedure
- /* choose the Lathe which is least busy */
- choose a queue from among Q_BufferLathe(1), Q_BufferLathe(2), Q_BufferLathe(3)
- whose current loads is minimum
- save choice as A_QptrLathe
- move into A_QptrLathe
- if Q_PaintingUnloading current = 0 then begin
- order 1 load from OL_PaintingUnloading to continue
- end
- set AI_LatheIndex = A_QptrLathe index
- move into Q_Lathe(AI_LatheIndex)
- /* processing time */
- use R_Lathe(AI_LatheIndex) for triangular 10, 12, 17 min
- move into Q_Final
- /* the product is finished */
- send to die
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement