transparent normal

------------------------------------------
STARTING = 0
RUNNING = 1
STOPPED = 2
maxcycles = 3
null = 0
NewRequest = 1
NewLocation = 1
NewMA = 1
------------------------------------------

channel Locationrequest

channel Starting,SendRequest_Failure,SendRequest_LUreceive,
        Calculate_Location_Failure,Calculate_Location,
        LU_Send_Location_Failure,SendLocation_OnBoardReceive,
        Send_Location_Failure,SendLocation_RBCreceive,
        Calculate_MA_Failure,Calculate_MA,
        Send_MA_Failure,SendMA_ReceiveMA,
        HandleMA,Stopped,step

Moving_Block(counter,STATUS,locationrequest,lureceive,lusend,
             onboardreceive,rbcreceive,rbcsend,receivema) =
             
-----------------------------------------------
--              Generation Request           --
-----------------------------------------------

   STATUS==RUNNING & counter <= maxcycles & receivema != NewMA
   & Locationrequest
   -> Moving_Block(counter+1,STATUS,NewRequest,lureceive,lusend,
             onboardreceive,rbcreceive,rbcsend,receivema)
--
-----------------------------------------------

-----------------------------------------------
--               Send Request                --
-----------------------------------------------
   []
   STATUS==RUNNING & counter <= maxcycles & receivema != NewMA
   & locationrequest == NewRequest 
   & SendRequest_Failure 
   -> Moving_Block(counter,STATUS,null,lureceive,lusend,
             onboardreceive,rbcreceive,rbcsend,receivema)
             
   []
   STATUS==RUNNING & counter <= maxcycles & receivema != NewMA
   & locationrequest == NewRequest 
   & SendRequest_LUreceive
   -> Moving_Block(counter,STATUS,null,NewRequest,lusend,
             onboardreceive,rbcreceive,rbcsend,receivema)
             
-----------------------------------------------
           
 
-----------------------------------------------
--           Calculate Location (CL)         --
-----------------------------------------------
   []
   STATUS==RUNNING & counter <= maxcycles & receivema != NewMA
   & lureceive == NewRequest 
   & Calculate_Location_Failure 
   -> Moving_Block(counter,STATUS,locationrequest,null,lusend,
             onboardreceive,rbcreceive,rbcsend,receivema) 
             
   []
   STATUS==RUNNING & counter <= maxcycles & receivema != NewMA
   & lureceive == NewRequest 
   & Calculate_Location
   -> Moving_Block(counter,STATUS,locationrequest,null,NewLocation,
             onboardreceive,rbcreceive,rbcsend,receivema) 


-----------------------------------------------
--           Sending Location (SL)         --
-----------------------------------------------
   []
   STATUS==RUNNING & counter <= maxcycles & receivema != NewMA
   & lusend == NewLocation 
   & LU_Send_Location_Failure 
   -> Moving_Block(counter,STATUS,locationrequest,lureceive,null,
             onboardreceive,rbcreceive,rbcsend,receivema) 
             
   []
   STATUS==RUNNING & counter <= maxcycles & receivema != NewMA
   & lusend == NewLocation 
   & SendLocation_OnBoardReceive
   -> Moving_Block(counter,STATUS,locationrequest,lureceive,null,
             NewLocation,rbcreceive,rbcsend,receivema) 

-----------------------------------------------
--        Send Location to RBC (SLRBC)       --
-----------------------------------------------
   []
   STATUS==RUNNING & counter <= maxcycles & receivema != NewMA
   & onboardreceive == NewLocation 
   & Send_Location_Failure
   -> Moving_Block(counter,STATUS,locationrequest,lureceive,lusend,
             null,rbcreceive,rbcsend,receivema) 
             
   []
   STATUS==RUNNING & counter <= maxcycles & receivema != NewMA
   & onboardreceive == NewLocation 
   & SendLocation_RBCreceive
   -> Moving_Block(counter,STATUS,locationrequest,lureceive,lusend,
             null,NewLocation,rbcsend,receivema)

-----------------------------------------------
--            Calculation of MA (CMA)        --
-----------------------------------------------
--
-- REQ: When CMA receives a location, CMA shall produce the MA
-- Note: The "produce MA" operation can fail
---------------------------------------------

   []
   STATUS==RUNNING & counter <= maxcycles & receivema != NewMA
   & rbcreceive == NewLocation 
   & Calculate_MA_Failure
   -> Moving_Block(counter,STATUS,locationrequest,lureceive,lusend,
             onboardreceive,null,rbcsend,receivema) 
             
   []
   STATUS==RUNNING & counter <= maxcycles & receivema != NewMA
   & rbcreceive == NewLocation 
   & Calculate_MA
   -> Moving_Block(counter,STATUS,locationrequest,lureceive,lusend,
             onboardreceive,null,NewMA,receivema)

-----------------------------------------------
--            Sending of MA (SMA)        --
-----------------------------------------------
    
   []
   STATUS==RUNNING & counter <= maxcycles & receivema != NewMA
   & rbcsend == NewMA 
   & Send_MA_Failure
   -> Moving_Block(counter,STATUS,locationrequest,lureceive,lusend,
             onboardreceive,rbcreceive,null,receivema) 
             
   []
   STATUS==RUNNING & counter <= maxcycles & receivema != NewMA
   & rbcsend == NewMA 
   & SendMA_ReceiveMA
   ->  Moving_Block(counter,STATUS,locationrequest,lureceive,lusend,
             onboardreceive,rbcreceive,null,NewMA)

-----------------------------------------------
--                Receive MA (RMA)           --
-----------------------------------------------
    
   []
   STATUS==RUNNING & receivema == NewMA
   & HandleMA
   ->  Moving_Block(0,STATUS,locationrequest,lureceive,lusend,
             onboardreceive,rbcreceive,rbcsend,null) 
             
   [] 
   STATUS==RUNNING & counter > maxcycles & receivema == null
   & Stopped
   -> Moving_Block(counter,STOPPED,locationrequest,lureceive,lusend,
           onboardreceive,rbcreceive,rbcsend,receivema)
           
    [] STATUS==STOPPED & Stopped
   -> Moving_Block(counter,STOPPED,locationrequest,lureceive,lusend,
           onboardreceive,rbcreceive,rbcsend,receivema)
             
-------------
             
SYS = Moving_Block(0,RUNNING,null,null,null,null,null,null,null)

--  Locationrequest,
HSYS= SYS\{|Locationrequest,SendRequest_Failure,SendRequest_LUreceive,
        Calculate_Location_Failure,Calculate_Location,
        LU_Send_Location_Failure,SendLocation_OnBoardReceive,
        Send_Location_Failure,SendLocation_RBCreceive,
        Calculate_MA_Failure,Calculate_MA,
        Send_MA_Failure,SendMA_ReceiveMA|}

--NSYS =normal(HSYS)

-------------
MBSTOP = Stopped -> MBSTOP

SPEC1 = step -> HandleMA ->  SPEC1 
       []
       step -> Stopped -> MBSTOP
       
SPEC = SPEC1\{step}

assert HSYS [FD= SPEC  -- OK   --  4 states
assert SPEC [FD= HSYS  -- OK   --289 states

assert SYS [FD= SYS    -- OK   --447 states 
-------------
    
