How can I select entity to specific output port in simevents?

1 回表示 (過去 30 日間)
Xinrui Qian
Xinrui Qian 2022 年 1 月 14 日
回答済み: Ravi 2024 年 1 月 23 日
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.

回答 (1 件)

Ravi
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.

カテゴリ

Help Center および File ExchangeSimEvents についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by