Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev' into df/#856-tap-water
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfeismann committed Aug 14, 2024
2 parents 8213012 + df66ad2 commit 927e856
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Changed format of example grid `vn_simona` [#216](https://github.com/ie3-institute/simona/issues/216)
- Renamed ChpData to ChpRelevantData [#494](https://github.com/ie3-institute/simona/issues/494)
- Updated gradle to 8.2.1, cleaned up `build.gradle` and `Jenkinsfile` [#572](https://github.com/ie3-institute/simona/issues/572)
- Changed implementation of actor naming for unique name generation [#103](https://github.com/ie3-institute/simona/issues/103)

### Fixed
- Location of `vn_simona` test grid (was partially in Berlin and Dortmund) [#72](https://github.com/ie3-institute/simona/issues/72)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ext {
jtsVersion = '1.19.0'
confluentKafkaVersion = '7.4.0'
tscfgVersion = '1.0.0'
scapegoatVersion = '2.1.6'
scapegoatVersion = '3.0.0'

testContainerVersion = '0.41.4'

Expand Down
21 changes: 10 additions & 11 deletions src/main/scala/edu/ie3/simona/actor/SimonaActorNaming.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,28 @@ import org.apache.pekko.actor.typed.ActorRef
import org.apache.pekko.actor.typed.scaladsl.adapter.TypedActorRefOps
import org.apache.pekko.actor.{ActorRefFactory, Props, ActorRef => ClassicRef}

import java.util.UUID
import scala.util.Random

object SimonaActorNaming {

implicit class RichActorRefFactory(private val refFactory: ActorRefFactory)
extends AnyVal {

def simonaActorOf(props: Props, actorId: String): ClassicRef =
refFactory.actorOf(props, actorName(props, actorId))

def simonaActorOf(props: Props): ClassicRef =
refFactory.actorOf(props, actorName(props, simonaActorUuid))
refFactory.actorOf(props, actorName(props, simonaActorId(actorId)))
}

/** Constructs a uuid and cuts it down to 6 digits for convenience. Although
* this is dangerous as duplicates might be possible, it should be sufficient
* in our case as the uniqueness is only required in one actor system
/** Constructs an Id for convenience actor naming. Although this is dangerous
* as duplicates might be possible, it should be sufficient in our case as
* the uniqueness is only required in one actor system
*
* @return
* a shortened uuid string
* an Id string
*/
private def simonaActorUuid: String =
UUID.randomUUID().toString.substring(0, 5)
private def simonaActorId(actorId: String): String = {
val randomNumber = Random.nextInt(1000).toString
s"$actorId-$randomNumber"
}

/** Constructs an actor name based on the simona convention for actor names.
* The provided combination of class and id has to be unique for the whole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,8 @@ class GridAgentController(
maybeControllingEm,
),
listener.map(_.toClassic),
)
),
evcsInput.getId,
)
.toTyped

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ class SimonaStandaloneSetup(
simulationStart,
),
simulationStart,
)
),
"primaryServiceProxyAgent",
)

scheduler ! ScheduleActivation(primaryServiceProxy.toTyped, INIT_SIM_TICK)
Expand All @@ -178,7 +179,8 @@ class SimonaStandaloneSetup(
.toZonedDateTime(simonaConfig.simona.time.startDateTime),
TimeUtil.withDefaults
.toZonedDateTime(simonaConfig.simona.time.endDateTime),
)
),
"weatherAgent",
)
weatherService ! SimonaService.Create(
InitWeatherServiceStateData(
Expand Down

0 comments on commit 927e856

Please sign in to comment.