*** This is a model of the simple train door given on Figure 2 in
*** the Verification of Cyberphysical Systems paper.

in lf-representation

omod TRAINDOOR is 
 including LF-REPR .
 
 ops moving locked : -> BVarId [ctor] .
 ops controller train door : -> ReactorId [ctor] .
 ops move lock : -> BPortId [ctor] .
 ops startup external : -> BActionId .
 op init : -> Configuration .
 
 eq init = 
    < controller : Reactor | 
      inports : none,
      outports : < lock : Port | value : [false] > 
                 < move : Port | value : [false] >, 
      state : empty,
      timers : none,
      actions : < startup : LogicalAction | minDelay : 0, 
                               minSpacing : 0, 
                               policy : defer, 
                               payload : [0] >
                < external : PhysicalAction | 
                               minDelay : 0, 
                               minSpacing : 0, 
                               policy : defer, 
                               payload : [false] >,
      reactions : 
        (reaction when startup do { skip })
        reaction when external --> lock ; move do
	{ (lock <- external ) ; (move <- external)}    --- for testing
    >
--- the startup stuff does not really do anything ...


    < train : Reactor | 
        inports : < move : Port | value : [false] >,
        outports : none,
        state : (moving |-> [false]), 
        timers : none,
        actions : none,
        reactions : reaction when move do { moving := move }       
    >
    
    < door : Reactor | 
        inports : < lock : Port | value : [false] >,
        outports : none,
        state : (locked |-> [false]),
        timers : none,
        actions : none,
        reactions : reaction when lock do { locked := lock }       
    >

    (controller : lock --> door : lock)
    controller : move --> train : move .
endom
