• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Scala-Robotics-Simulator / PPS-22-srs / #583

04 Sep 2025 08:29PM UTC coverage: 80.49% (+25.3%) from 55.207%
#583

push

github

GiuliaNardicchia
refactor: simplify comments in BehaviorTypes

1576 of 1958 relevant lines covered (80.49%)

11.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.74
/src/main/scala/io/github/srs/model/SimulationState.scala
1
package io.github.srs.model
2

3
import scala.concurrent.duration.{ FiniteDuration, MILLISECONDS }
4

5
import io.github.srs.config.SimulationConfig
6
import io.github.srs.model.SimulationConfig.{ SimulationSpeed, SimulationStatus }
7
import io.github.srs.model.environment.ValidEnvironment
8
import io.github.srs.utils.random.{ RNG, SimpleRNG }
9

10
/**
11
 * Simulation state case class that holds the current state of the simulation.
12
 * @param simulationTime
13
 *   the current simulation time, if applicable.
14
 * @param elapsedTime
15
 *   the elapsed time since the start of the simulation.
16
 * @param dt
17
 *   the time step for each simulation update.
18
 * @param simulationSpeed
19
 *   the speed at which the simulation is running.
20
 * @param simulationRNG
21
 *   the random number generator used in the simulation.
22
 * @param simulationStatus
23
 *   the current status of the simulation.
24
 * @param environment
25
 *   the current environment of the simulation.
26
 */
27
final case class SimulationState(
28
    override val simulationTime: Option[FiniteDuration],
46✔
29
    override val elapsedTime: FiniteDuration = FiniteDuration(0, MILLISECONDS),
6✔
30
    override val dt: FiniteDuration = FiniteDuration(100, MILLISECONDS),
20✔
31
    override val simulationSpeed: SimulationSpeed,
20✔
32
    override val simulationRNG: RNG,
6✔
33
    override val simulationStatus: SimulationStatus,
6✔
34
    override val environment: ValidEnvironment,
6✔
35
) extends ModelModule.State
6✔
36

37
/**
38
 * Companion methods for the [[ModelModule.State]] to provide pretty-printing functionality.
39
 */
40
object SimulationState:
41

×
42
  /**
43
   * Creates the initial state of the simulation based on the provided configuration.
44
   *
45
   * @param cfg
46
   *   the simulation configuration to use for initializing the state
47
   * @return
48
   *   the initial state of the simulation
49
   */
50
  def from(cfg: SimulationConfig[ValidEnvironment], headless: Boolean): SimulationState =
51
    val speed = if headless then SimulationSpeed.SUPERFAST else SimulationSpeed.NORMAL
9✔
52
    val status = if headless then SimulationStatus.RUNNING else SimulationStatus.PAUSED
9✔
53
    val rng = SimpleRNG(cfg.simulation.seed.getOrElse(42))
9✔
54
    SimulationState(
13✔
55
      simulationTime = cfg.simulation.duration.map(FiniteDuration(_, MILLISECONDS)),
17✔
56
      simulationSpeed = speed,
11✔
57
      simulationRNG = rng,
1✔
58
      simulationStatus = status,
1✔
59
      environment = cfg.environment,
1✔
60
    )
5✔
61
end SimulationState
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc