/**
 * Copyright (c) 2021, 2025 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
    RTUnclamp: Robot.take.C.clamp
    RGClamp: Robot.give.C.clamp
    RGUnclamp: Robot.give.C.unclamp
    FFlip: move Flipper.F for HalfRound with speed profile normal // <2>
    FClamp: Flipper.C.clamp
    FUnclamp: Flipper.C.unclamp
  }
  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 RobotStart {  // <3>
  prerequisites { 
    Robot.M at Home
  }
  actions { 
    Claim: claim Robot
    Release: release Robot
    MoveTransfer: move Robot.M to Transfer with speed profile normal
  }
  action flow {
    Claim -> MoveTransfer ->  Release 
  }
}

activity RobotStop { // <3>
  prerequisites { 
    Robot.M at Transfer
  }
  actions { 
    Claim: claim Robot
    Release: release Robot
    MoveHome: move Robot.M to Home with speed profile normal
  }
  action flow {
    Claim -> MoveHome ->  Release 
  }
}