How can I select entity to specific output port in simevents?
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm trying to simulate a production system, idea is that, the customer order one product with type 1 or 2 or 3, which is random generated by using attribute. In production area, there are machine A1 B1 C1 A2 B2 C2, A for operation OP1, B for OP2, and C for OP 3, product type 1 need OP1 and OP2, product type 2 needs OP2 and OP3, type 3 needs OP3 and OP1. all operation with arbitrary sequence. what I wanna do is, let the control system using stateflow to decide which machine should take the Order, if the machine is not busy. if the operation steps are finished, the order will be taken to terminator.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/863295/image.png)
댓글 수: 0
답변 (1개)
Ravi
2024년 1월 23일
Hi Xinrui Qian,
I will provide you a pseudo code about how the chart should be designed, since the interpretation of variables is unclear from the screenshot you have attached. Also, what parameters determine if the machine is busy or available is unclear. You can create the stateflow chart as follows.
Pseudocode:
state Idle
on: new_order % IN variable has some value in it.
if product_type == 1 then
transition to State_OP1_for_Type1
elseif product_type == 2 then
transition to State_OP2_for_Type2
else
transition to State_OP3_for_Type3
end
%---------------------%
state State_OP1_for_Type1
on: entry
if A1_not_busy then
assign A1
transition to State_OP2_for_Type1
elseif A2_not_busy then
assign A2
transition to State_OP2_for_Type1
else
stay in State_OP1_for_Type1
end
%---------------------%
state State_OP2_for_Type1
on: entry
if B1_not_busy then
assign B1
transition to Order_Completed
elseif B2_not_busy then
assign B2
transition to Order_Completed
else
stay in State_OP2_for_Type1
end
%---------------------%
state Order_Completed
on: entry
send_order_to_terminator
transition to Idle
In the above pseudocode, you can add similar states for type 2 and type 3, “State_OP2_for_Type2”, “State_OP3_for_Type3” for type 2 and “State_OP1_for_Type3” and “State_OP3_for_Type1” for type 3.
Let us assume a new order with type 1 has arrived into the system. The Idle state, identifies a new order and passes it to the “State_OP1_for_Type1” state. Here, if “A1” is available, then after processing, it is sent to “State_OP2_for_Type1”. If “A1” is busy, then “A2” is checked. If we find that both “A1”, and “A2” are busy, then call the same state again until any of the machine is free. Once, it passes both the operations, transition it to the “Order_Completed” state.
I hope this provides a way to solve the issue you are facing.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Discrete-Event Simulation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!