/**
 * Copyright (c) 2021, 2026 Contributors to the Eclipse Foundation
 *
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 */
import "tutorial_ext.machine"

activity MoveAndFlip { 
  prerequisites {
    Robot.give.M at Transfer
    Robot.take.M at Transfer
  }
  actions {
    RGClaim: claim Robot.give // <1>
    RGRelease: release Robot.give
    FClaim: claim Flipper
    FRelease: release Flipper
    RTClaim: claim Robot.take
    RTRelease: release Robot.take
    RGMoveFlip: move Robot.give.M to Flip with speed profile normal
    RGMoveTransfer: move Robot.give.M to Transfer with speed profile slow
    RTMoveFlip: move Robot.take.M to Flip with speed profile normal
    RTMoveTransfer: move Robot.take.M to Transfer with speed profile slow 
    RTClamp: Robot.take.C.clamp in transfer2// <2>
    RGUnclamp: Robot.give.C.unclamp out transfer1 // <3>
    RGClamp: Robot.give.C.clamp entry @start (flipped: False) // <4>
    RTUnclamp: Robot.take.C.unclamp exit // <5>
    FUnclamp: Flipper.C.unclamp out transfer2 @start(flipped : True) // <6>
    FClamp: Flipper.C.clamp in transfer1 // <7>
    FFlip: move Flipper.F for HalfRound with speed profile normal // <8>
    
  }
  action flow {
    RGClaim -> RGClamp -> RGMoveFlip -> FClaim->FClamp -> RGUnclamp -> |S1 ->FFlip -> |S2
    RTClaim -> RTMoveFlip -> |S2
    |S1 -> RGMoveTransfer -> RGRelease
    |S2 -> RTClamp -> FUnclamp -> FRelease-> RTMoveTransfer -> RTUnclamp -> RTRelease
  }
}

activity RobotMove(robot: Robot, start, end : SymbolicPosition) {  // <9>
  prerequisites { 
    robot.M at start
  }
  actions { 
    Claim: claim robot
    Release: release robot
    MoveTransfer: move robot.M to end with speed profile normal
  }
  action flow {
    Claim -> MoveTransfer ->  Release 
  }
}