From 17bb0205c577720ab5137729d619b1f3cc71297e Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 21 Nov 2019 14:36:02 +0100 Subject: docs: Move odcsim docs to separate directory --- odcsim/README.md | 52 +++++----------------------------------------------- 1 file changed, 5 insertions(+), 47 deletions(-) (limited to 'odcsim/README.md') diff --git a/odcsim/README.md b/odcsim/README.md index 5863b055..e5dcc319 100644 --- a/odcsim/README.md +++ b/odcsim/README.md @@ -7,12 +7,12 @@ ## Introduction -**odcsim** is a framework for discrete event simulation in Kotlin and Java, used +**odcsim** is a framework for discrete event simulation in Kotlin, used by the [OpenDC](https://opendc.org) project. Simulations are defined in terms of a hierarchical grouping of actors and the interactions between these actors ([Actor model](https://en.wikipedia.org/wiki/Actor_model)), using -an API very similar to [Akka Typed](https://doc.akka.io/docs/akka/current/typed/index.html). +an API similar to [Akka](https://doc.akka.io/docs/akka/current/index.html). ## Documentation Check out the [Getting Started](#getting-started) section for a quick @@ -37,12 +37,12 @@ model. #### Gradle Groovy ```groovy -implementation 'com.atlarge.odcsim:odcsim-core:2.0.0' +implementation 'com.atlarge.odcsim:odcsim-api:2.0.0' runtime 'com.atlarge.odcsim:odcsim-engine-omega:2.0.0' ``` Kotlin ```groovy -implementation("com.atlarge.odcsim:odcsim-core:2.0.0") +implementation("com.atlarge.odcsim:odcsim-api:2.0.0") runtime("com.atlarge.odcsim:odcsim-engine-omega:2.0.0") ``` @@ -50,7 +50,7 @@ runtime("com.atlarge.odcsim:odcsim-engine-omega:2.0.0") ```xml com.atlarge.odcsim - odcsim-core + odcsim-api 2.0.0 @@ -61,45 +61,3 @@ runtime("com.atlarge.odcsim:odcsim-engine-omega:2.0.0") ``` -### Construction of Simulation Model -Let's construct a simple simulation model of a single car actor. -The car will alternately drive and park for a while. When it starts -driving (or parking), it will print the current simulation time. - - -```kotlin -import com.atlarge.odcsim.Behavior -import com.atlarge.odcsim.coroutines.suspending -import com.atlarge.odcsim.coroutines.dsl.timeout - -fun car(): Behavior = - suspending { ctx -> - while (true) { - println("Start parking at ${ctx.time}") - val parkingDuration = 5.0 - timeout(parkingDuration) - - println("Start driving at ${ctx.time}") - val tripDuration = 2.0 - timeout(tripDuration) - } - - stopped() - } -``` - -### Running Simulation -Running the constructed simulation model requires an implementation -of the `ActorSystem` interface provided by one of the `odcsim-engine-*` -packages. The [ServiceLoader](https://docs.oracle.com/javase/9/docs/api/java/util/ServiceLoader.html) -class found in the JDK can be used to locate the `ActorSystem` implementation on the classpath. -```kotlin -import com.atlarge.odcsim.ActorSystemFactory -import java.util.ServiceLoader - -val factory = ServiceLoader.load(ActorSystemFactory::class.java).first() -val system = factory(car(), name = "car") -system.run(until = 10.0) -system.terminate() -``` - -- cgit v1.2.3