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

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

18 Aug 2025 12:42PM UTC coverage: 61.478% (-15.7%) from 77.166%
#310

push

github

srs-mate
refactor: update RobotActionLogic to use robot parameter directly and enable debug mode

1 of 4 new or added lines in 2 files covered. (25.0%)

309 existing lines in 26 files now uncovered.

932 of 1516 relevant lines covered (61.48%)

8.82 hits per line

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

0.0
/src/main/scala/io/github/srs/model/ModelModule.scala
1
package io.github.srs.model
2

3
import scala.concurrent.duration.FiniteDuration
4

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

10
/**
11
 * Module that defines the model logic for the Scala Robotics Simulator.
12
 */
13
object ModelModule:
UNCOV
14

×
15
  /**
16
   * State trait that defines the base state for the simulation.
17
   */
18
  trait State:
UNCOV
19

×
20
    /**
21
     * The total simulation time for the simulation.
22
     */
23
    def simulationTime: Option[FiniteDuration]
24

25
    /**
26
     * The elapsed time since the start of the simulation.
27
     */
28
    def elapsedTime: FiniteDuration
29

30
    /**
31
     * The delta time for the simulation, which is the time step used in the simulation.
32
     */
33
    def dt: FiniteDuration
34

35
    /**
36
     * The current simulation speed.
37
     */
38
    def simulationSpeed: SimulationSpeed
39

40
    /**
41
     * The random number generator used for the simulation.
42
     */
43
    def simulationRNG: RNG
44

45
    /**
46
     * The current simulation status.
47
     */
48
    def simulationStatus: SimulationStatus
49

50
    def environment: ValidEnvironment
51
  end State
52

53
  /**
54
   * Trait representing the core model logic for updating the simulation state.
55
   *
56
   * @tparam S
57
   *   the type of the simulation state, which must extend [[State]].
58
   */
59
  trait Model[S <: State]:
60
    /**
61
     * Updates the state of the simulation using the provided function.
62
     *
63
     * @param s
64
     *   the current state of the simulation.
65
     * @param f
66
     *   the function that takes the current state and returns a new state wrapped in a [[IO]].
67
     * @return
68
     *   the updated state wrapped in a [[IO]].
69
     */
70
    def update(s: S)(using f: S => IO[S]): IO[S]
71

72
  /**
73
   * Provider trait that defines the interface for providing a model.
74
   *
75
   * @tparam S
76
   *   the type of the state, which must extend [[State]].
77
   */
78
  trait Provider[S <: State]:
79
    val model: Model[S]
80

81
  /**
82
   * Component trait that defines the interface for creating a model.
83
   *
84
   * @tparam S
85
   *   the type of the simulation state, which must extend [[State]].
86
   */
87
  trait Component[S <: State]:
UNCOV
88

×
89
    object Model:
UNCOV
90

×
91
      /**
92
       * Factory method to create a new instance of the model.
93
       *
94
       * @return
95
       *   a new instance of [[Model]].
96
       */
97
      def apply(): Model[S] = new ModelImpl
UNCOV
98

×
99
      /**
100
       * Private model implementation that delegates state updates to the provided function.
101
       */
102
      private class ModelImpl extends Model[S]:
UNCOV
103
        /**
×
104
         * @inheritdoc
105
         */
106
        override def update(s: S)(using updateLogic: S => IO[S]): IO[S] = updateLogic(s)
UNCOV
107
  end Component
×
108

109
  /**
110
   * Interface trait that combines the provider and component traits.
111
   *
112
   * @tparam S
113
   *   the type of the state, which must extend [[State]].
114
   */
115
  trait Interface[S <: State] extends Provider[S] with Component[S]
116
end ModelModule
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