Skip to contents

These bricks encapsulate a resource visit: seize, spend some time and release.

Usage

visit(.trj, resource, task, amount = 1)

visit_selected(.trj, task, amount = 1, id = 0)

Arguments

.trj

the trajectory object.

resource

the name of the resource.

task

the timeout duration supplied by either passing a numeric or a callable object (a function) which must return a numeric (negative values are automatically coerced to positive).

amount

the amount to seize/release, accepts either a numeric or a callable object (a function) which must return a numeric.

id

selection identifier for nested usage.

Value

Returns the following chain of activities: seize

> timeout > release

(see examples below).

Examples

## These are equivalent:
trajectory() %>%
  visit("res", 5, 1)
#> trajectory: anonymous, 3 activities
#> { Activity: Seize        | resource: res, amount: 1 }
#> { Activity: Timeout      | delay: 5 }
#> { Activity: Release      | resource: res, amount: 1 }

trajectory() %>%
  seize("res", 1) %>%
  timeout(5) %>%
  release("res", 1)
#> trajectory: anonymous, 3 activities
#> { Activity: Seize        | resource: res, amount: 1 }
#> { Activity: Timeout      | delay: 5 }
#> { Activity: Release      | resource: res, amount: 1 }

## These are equivalent:
trajectory() %>%
  visit_selected(5, 1)
#> trajectory: anonymous, 3 activities
#> { Activity: Seize        | resource: [0], amount: 1 }
#> { Activity: Timeout      | delay: 5 }
#> { Activity: Release      | resource: [0], amount: 1 }

trajectory() %>%
  seize_selected(1) %>%
  timeout(5) %>%
  release_selected(1)
#> trajectory: anonymous, 3 activities
#> { Activity: Seize        | resource: [0], amount: 1 }
#> { Activity: Timeout      | delay: 5 }
#> { Activity: Release      | resource: [0], amount: 1 }