(************************************************************ * IMITATOR * * Modeling the FMTV challenge, problem 1B for n=1 * * Author : Giuseppe Lipari * Created : 2015/03/19 * Last modified : 2015/04/24 * IMITATOR version: 2.7 * * This version has different initialization: * * p3 = 1, p4 = 0 * distance >= 0 * rep_max = 2 * buffer34 = 0 (empty) * * Fixed sequence (2,4) ************************************************************) var (** CONSTANTS **) INDEX_MAX = 3, (*Generates frame indexes btw 0, 1, 2*) P3 = 13332, P4 = 40004, : parameter; (** CLOCKS **) p3, p4, distance : clock; (** DISCRETE **) frame_index, (* this is the frame produced by T3 *) buffer34, (* this is 1 if the buffer is full, 0 if empty *) buffer_last, (* this is the index of the last frame written in the buff *) rep_max, (* max number of repetitions of one frame *) rep, (* current counter of repetition, 0 <= rep < rep_max *) : discrete; (** PARAMETERS **) D_MIN : parameter; (* the minimum distance *) (* no parameters for the moment *) (** RELEASE PATTERN **) automaton ReleasePattern synclabs : produce_rep_max; loc BCL : while True wait {} when True sync produce_rep_max do { rep_max'=4 } goto WCL; loc WCL : while True wait {} when True sync produce_rep_max do { rep_max'=2 } goto BCL; end (** T3 produces frames **) automaton T3 synclabs: produce_rep_max, frame_loss; loc T3_wait : while p3 <= P3 wait {} when p3 = P3 do { p3'=0,rep'=rep+1} goto T3_check_rep; loc T3_check_rep : while p3 <= 0 wait {} when p3 = 0 & rep = rep_max & frame_index = buffer_last (* OK, I wrote this *) sync produce_rep_max do { rep'=0, frame_index'=frame_index+1 } goto T3_check_frame; when p3 = 0 & rep = rep_max & frame_index > buffer_last (* FRAME LOSS !*) sync produce_rep_max do { rep'=0, frame_index'=frame_index+1 } goto T3_frame_loss; when p3 = 0 & rep = rep_max & frame_index < buffer_last (* FRAME LOSS !*) sync produce_rep_max do { rep'=0, frame_index'=frame_index+1 } goto T3_frame_loss; when p3 = 0 & rep < rep_max do {} goto T3_produce_frame; loc T3_frame_loss : while p3 <= 0 wait {} when p3 = 0 sync frame_loss do {} goto T3_check_frame; loc T3_check_frame : while p3 <= 0 wait {} when p3 = 0 & frame_index = INDEX_MAX do { frame_index'=0 } goto T3_produce_frame; when p3 = 0 & frame_index < INDEX_MAX do {} goto T3_produce_frame; loc T3_produce_frame : while p3 <=0 wait {} when p3 = 0 & buffer_last = frame_index (* Discard frame (written already) *) do {} goto T3_wait; when p3 = 0 & buffer34 = 1 & buffer_last < frame_index (* Discard frame (buffer full) *) do {} goto T3_wait; when p3 = 0 & buffer34 = 1 & buffer_last > frame_index (* Discard frame (buffer full) *) do {} goto T3_wait; when p3 = 0 & buffer34 = 0 & buffer_last < frame_index (* Write frame (buffer empty) *) do { buffer_last'=frame_index, buffer34'=1 } goto T3_wait; when p3 = 0 & buffer34 = 0 & buffer_last > frame_index (* Write frame (buffer empty) *) do { buffer_last'=frame_index, buffer34'=1 } goto T3_wait; end (* T3 *) (* T4: the consumer *) automaton T4 synclabs: ; loc T4_wait : while p4 <= P4 wait{} when p4 = P4 do { p4'=0, buffer34'=0 } goto T4_wait; end (* T4 *) (* The Observer, computes the distance *) automaton Obs synclabs: frame_loss; loc Obs_init : while True wait {} when True sync frame_loss do { distance '= 0 } goto Obs_observe; loc Obs_observe: while True wait {} when distance < D_MIN sync frame_loss do {} goto Obs_error; when distance >= D_MIN sync frame_loss do {distance '= 0} goto Obs_observe; loc Obs_error : while True wait {} when True do {} goto Obs_error; end (************************************************************) (* Analysis *) (************************************************************) init := True (* init locations *) & loc[ReleasePattern] = BCL & loc[T3] = T3_wait & loc[T4] = T4_wait & loc[Obs] = Obs_init (* init clocks *) & p3 = 1 & p4 = 0 & distance >= 0 (* init discrete *) & buffer34 = 0 & buffer_last = 0 & frame_index = 1 & rep = 0 & rep_max = 2 ; property := unreachable loc[Obs] = Obs_error; projectresult(D_MIN);