pbernet / scala_gear_simulation

A simulation of synchronizing gears modeled with akka-actors and scala-swing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Synchronizing gear simulation in Scala

Introduction

A simulation of synchronizing gears modeled with akka-actors and scala-swing

Clone and run with:

mvn

Or run the main class GearGUI from the IDE.

Concepts

Concepts

  • Each Gear is an Akka Actor which is represented in the GearGUI by a slider
  • The gears are supervised by the GearController Actor which coordinates and keeps the state
  • The Receiver Actor coordinates updates from the GearController to the GearGUI

What is the purpose of...

...the slider colors:

  • green: Gear is synced (= has the same speed as the calculated sync speed)
  • yellow: Gear in progress
  • red: Gear has been sabotaged (= a new speed was forced)
  • magenta: Gear had an exception and is restarted by the supervisor
  • black: Gear had 2 exceptions within 2 seconds (double click to revive)

Gear GUI

...the parameters in the code:

  • GearGUI nOfGears (increase if you want to have more gears)
  • Gear errorLevel (raise initial value here to have more exceptions or use Slider in GUI)
  • Gear sleepTime (raise initial value here to slow down simulation or use Slider in GUI)

History

Update to akka 2.5.23 and Scala 2.13.0

  • Update pom.xml, note that scala-swing is now maintained by the community
  • Remove obsolete stuff and minor refactorings

Update to akka 2.5.4 and Scala 2.11.11

  • Update pom.xml
  • Adjust the params in Gear for faster completion
  • Add deprecated note for Typesafe Console

Update to akka 2.3.8 and Scala 2.11.4

  • Set the ErrorLevel via Slider from GUI
  • Run Application via sbt-atmos plug-in
  • Usage of Typesafe Console (deprecated) via via sbt-atmos plug-in
./sbt
> atmos:run-main ch.clx.geargui.GearGUI
[info] Starting Atmos and Typesafe Console ...
[info] Typesafe Console is available at http://localhost:9900

Update to akka 2.2.3

  • Change the gear actor behaviour with "akka become", so there is no need for a local var "speed" anymore
  • Minor enhancements: Removed ActorRefs in Messages
  • Added sbt and support for monitoring with Typesafe Console via sbt-atmos plug-in https://github.com/sbt/sbt-atmos

Update to akka 2.1.0 and Scala 2.10 (this branch)

  • Forked from dhob/scala_gear_simulation
  • Changed akka implementation from 1.3 -> 2.0 -> 2.1 using the akka migration guides
  • Fault Tolerance through Supervisor Strategies a(k)ka "Let it crash"
  • Minor enhancements to the GUI

Monitoring

  • YourKit for thread activity
  • Typesafe Console via sbt-atmos plug-in

About

A simulation of synchronizing gears modeled with akka-actors and scala-swing


Languages

Language:Scala 100.0%