Download General Purpose Petri Net Simulator
Transcript
24.4.3 Pre-processor for T1, T2, T3, T4 and T9: The only job of the preprocessors T1_pre to T4_pre, and T9_pre is to grab an available so that they can start. However, the preprocessors for T5-T8 have one more job to do, that is to make sure that they fire only once (or consume only one token after T4 has fired). Pre-processor for T1, T2, T3, T4 and T9 are similar: function [fire, new_color,override,selected_tokens,global_info] = ... T1_pre(PN, new_color,override,selected_tokens,global_info) % T1_pre task_nr = 1; % TASK-1 occu_semafor = global_info.semafor; semafor = ~occu_semafor; [row, cols] = find(semafor); % find any available semafor (value ~= 0) if ~isempty(cols), sema = cols(1); % which is the first avialble semafor global_info.my_semafor(task_nr) = sema; % that will be mine global_info.semafor(sema) = task_nr; % then reserve it % pack results global_info.timing(task_nr, 1) = sema; % task handler global_info.timing(task_nr, 2) = PN.current_time; % task starting time fire = 1; else fire = 0; end; Pre-processor for T5, T6, T7, and T8 are similar; they first check whether the transition is already fired once. If yes, then no more firing. Other wise, they try to grab a semafor. function [fire, new_color,override,selected_tokens,global_info] = ... T5_pre(PN, new_color,override,selected_tokens,global_info) % T5_pre task_nr = 5; % TASK-5 occu_semafor = global_info.semafor; semafor = ~occu_semafor; [row, cols] = find(semafor); % find any available semafor (value ~= 0) tx = get_trans(PN, 'T5'); 125